Learn Ruby
Array
14.4
Lesson

reject to remove certain items from array

We have an array of numbers and we want to remove all the odd numbers from that array.

Above code works but Array provides reject to reject certain items. reject will only reject items for which the result of condition is true. Let’s see it in action.