Flowdock
method

extract!

Importance_1
v6.1.3.1 - Show latest stable - 0 notes - Class: Array
extract!() public

Removes and returns the elements for which the block returns a true value. If no block is given, an Enumerator is returned instead.

numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
numbers # => [0, 2, 4, 6, 8]
Show source
Register or log in to add new notes.