Chris Mendez in For Developers, Ruby

Ruby Enumberable

I doubt many people will need this but here are a few neat things you can do with Ruby. I won't go into great detail but it's methods like these that have me still loving ruby for its elegance.

Anything in your collection will satisfy a given condition

[1,2,3,4,5].any?(&:even?) #true

Use all to determine if all items in your collection fulfill that condition


Use find to get the first item in that collection to meet your condition


Use reject as the opposite of select. Anything that met your criteria, was excluded from your list