Skip to content

Instantly share code, notes, and snippets.

@markyv18
Last active December 2, 2016 06:35
Show Gist options
  • Save markyv18/7493d9923dafbbc795dea0c87a064789 to your computer and use it in GitHub Desktop.
Save markyv18/7493d9923dafbbc795dea0c87a064789 to your computer and use it in GitHub Desktop.
Eloquent Ruby
#1
a_bunch_of_numbers = [1,2,3,4,5,6]
p a_bunch_of_numbers.first
p a_bunch_of_numbers.last
#2
animals = ["dog", "cat", "goat", "capybara"]
animals_capitalized = animals.map(& :capitalize)
animals_capitalized.join(", ")
#3
BANG! permanently alter the original object
Adv- no need to build new array with altered types. Disadv- you've altered the source material.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment