Module: ArrayExtensions
- Included in:
- Array
- Defined in:
- lib/array_extensions.rb
Instance Method Summary collapse
-
#remove_first(&test) ⇒ Object
removes the first entry in the array for which the test returns true.
Instance Method Details
#remove_first(&test) ⇒ Object
removes the first entry in the array for which the test returns true
11 12 13 14 15 16 17 |
# File 'lib/array_extensions.rb', line 11 def remove_first(&test) self.each_index do |index| return self.delete_at(index) if test.call(self[index]) end nil # nothing removed, nothing to return end |