Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/gluttonberg/extensions/array.rb
Instance Method Summary (collapse)
-
- (Object) pluck(&blk)
Accepts a block and returns the first element for which the block returns true.
Instance Method Details
- (Object) pluck(&blk)
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 |