select

struct.select {|i| block } â array
struct.select â an_enumerator
Instance Public methods

Invokes the block passing in successive elements from struct, returning an array containing those elements for which the block returns a true value (equivalent to Enumerable#select).

Lots = Struct.new(:a, :b, :c, :d, :e, :f)
l = Lots.new(11, 22, 33, 44, 55, 66)
l.select {|v| (v % 2).zero? }   #=> [22, 44, 66]
doc_ruby_on_rails
2015-05-16 05:57:29
Comments
Leave a Comment

Please login to continue.