Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/gluttonberg/extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#pluck(&blk) ⇒ Object

Accepts a block and returns the first element for which the block returns true.



5
6
7
8
9
10
11
# File 'lib/gluttonberg/extensions/array.rb', line 5

def pluck(&blk)
  i = 0
  while i < length
    return self[i] if blk.call(self[i])
    i += 1
  end
end