On Jul 31, 2013, at 12:05 AM, Joel Turnbull <
joel...@gmail.com> wrote:
>
> reject!{|p| p == self}
>
> Is there a better way to write that?
Whoa! Mind slightly blown here. So we have a container, and we iterate through the container and reject elements of the container that are the entire container itself (and then set the container to the new container-less result).
I suppose that's possible, e.g.
a = []
a[0] = a
a # => [[...]]
def a.remove_self; reject! { |p| p == self }; end
a.remove_self
a # => []
Oh, to answer your question, I don't know of a demonstrably better way to write that line.
--
-- Jim Weirich / neo
-- Chief Scientist