Skip to content

Instantly share code, notes, and snippets.

@telegraham
Last active September 15, 2018 14:54
Show Gist options
  • Save telegraham/3f823b4b32ad0cc2a404ae08feff2b06 to your computer and use it in GitHub Desktop.
Save telegraham/3f823b4b32ad0cc2a404ae08feff2b06 to your computer and use it in GitHub Desktop.
dogs = [
{
name: "fido",
age: 4,
likes: ["play fetch", "bark", "piddle"]
},
{
name: "spot",
age: 10,
likes: ["sleep"]
},
{
name: "rover",
age: 6,
likes: ["chasing own tail", "rolling in dead things"]
}
]
## .each
# Used for:
# Method returns:
# Block should return:
# sample usage
dogs.each do |dog|
# do something clever here
end
## .map
# Used for:
# Method returns:
# Block should return:
# sample usage
dogs.map do |dog|
# do something clever here
end
## .select
# Used for:
# Method returns:
# Block should return:
# sample usage
dogs.select do |dog|
# do something clever here
end
## .find
# Used for:
# Method returns:
# Block should return:
# sample usage
dogs.find do |dog|
# do something clever here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment