From: Michael Neumann Date: 2003-11-20T18:16:01+09:00 Subject: Re: x.f! RCR On Thu, Nov 20, 2003 at 03:38:51PM +0900, Dan Doel wrote: > Well, I agree. However, I would argue that there should be a #delete > and #delete! for that very reason. > > I was merely arguing that #delete doesn't necessarily have to modify the > array in place you could have: > > a = ["a", "b", "b", "c"] > > b = a.delete "b" delete actually returns the removed element ("b" in this case) or nil if no element to delete was found. It does not return the array. a = ["a", "b", "b", "c"] a.delete "b" # => "b" a.delete "b" # => nil (no more "b" in a) a.delete "x" # => nil (no "x" in a) So it can't be modified for non-destructive deletion this way. What you want in #reject (indeed #reject is more general than #delete, as it's part of Enumerable, not just Array). a = ["a", "b", "b", "c"] b = a.reject {|e| e == "b"} Here the #reject! method works as expected. Regards, Michael