Bug #2725: Return values of Array#compact! and delete: rdoc improvement.
http://redmine.ruby-lang.org/issues/show/2725

Author: Hugh Sasse
Status: Open, Priority: Normal
ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]

I wanted further clarification about what happens when items are not found when they are expected.  The attached patch meets my needs, hopefully those of others.  Documented behaviour checked with irb:

18:32:30$ irb
irb(main):001:0> a = ["pike", "carp", "trout"]
=> ["pike", "carp", "trout"]
irb(main):002:0> a.delete("trout")
=> "trout"
irb(main):003:0> a.delete("herring")
=> nil
irb(main):004:0> a.compact!
=> nil
irb(main):005:0> a.push nil
=> ["pike", "carp", nil]
irb(main):006:0> a.compact!
=> ["pike", "carp"]
irb(main):007:0>


----------------------------------------
http://redmine.ruby-lang.org