Last active
December 2, 2016 06:35
-
-
Save markyv18/7493d9923dafbbc795dea0c87a064789 to your computer and use it in GitHub Desktop.
Eloquent Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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