> a = %w(a b c)
=> ["a", "b", "c"]
> a.select!{|e| !e.nil?}
NoMethodError: undefined method `select!' for ["a", "b", "c"]:Array
from (irb):2
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.5.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02
The doc says there is a method called select! in array.
http://www.ruby-doc.org/core/classes/Array.html#M000252
Ruby 1.8.7 does have Array#reject!
, though:
>> a = [1, 2, nil]
=> [1, 2, nil]
>> a.reject! &:nil?
=> [1, 2]
The docs you linked to are for Ruby 1.9.2. Ruby 1.8.7 Arrays don't have select!
.
EDIT: As a future reference, you can view documentation for the different versions of Ruby that are out there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With