Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My Enumerable Methods Cheat Sheet

#Iteration Methods

##.each Grabs each item in the array so the declared variable represents the object rather than the value of the object. This is different than iterating through an array by the index.

### .each iteration example
numbers = [1,2,3,4]
numbers.each do |number|
  puts number
end


### index-based iteration example
numbers = [1,2,3,4]
(numbers.length).times do |i|
  number = numbers[i]
  puts number
end

##.map

##.sort_by

#Filter Methods

##.find

##.find_all

##.reject

#Boolean Methods

##.all?

##.any?

##.none?

##.one?

#One Value Methods

##.reduce

##.max_by

##.min_by

#New Collection Methods

##.group_by

##.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment