From: Dave Thomas Date: 2003-12-29T10:51:28+09:00 Subject: Re: An addition to Array (or Enumerable)? On Dec 28, 2003, at 18:15, Gennady wrote: > Strange, ri 1.8b claims that Array#select([anIndex]*) may be used, > however I got this error: It changed... :) The new ri has it right: dave[ruby/ruby 17:06:31] ri -f bs Array.select ----------------------------------------------------------- Array#select array.select {|i| block } -> an_array ------------------------------------------------------------------------ Invokes the block passing in successive elements from arr, returning an array containing those elements for which the block returns a true value (equivalent to Enumerable#select). a = %w{ a b c d e f } a.select(1, 3, 5) #=> ["b", "d", "f"] a.select(1, 3, 5, 7) #=> ["b", "d", "f", nil] a.select(-1, -3, -5, -7) #=> ["f", "d", "b", nil] a.select {|v| v =~ /[aeiou]/} #=> ["a", "e"] Cheers Dave