Skip to content

Instantly share code, notes, and snippets.

@AELSchauer
Last active December 11, 2016 01:34
Show Gist options
  • Save AELSchauer/d832b1df90f84d884a623b2c56f739d0 to your computer and use it in GitHub Desktop.
Save AELSchauer/d832b1df90f84d884a623b2c56f739d0 to your computer and use it in GitHub Desktop.
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