Created
January 13, 2015 23:08
-
-
Save aguayma/f57ee57f41744f9cdcb6 to your computer and use it in GitHub Desktop.
My Favorite Questions So Far....
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
puts <<first | |
1 Push It, Push It Good | |
What’s the difference between these two Ruby expressions? | |
[1,2,3].push(1,2,3) | |
[1,2,3].push([1,2,3]) | |
#You can push items into an array, and it will append the original array | |
#with the new data at the end. | |
1a The first results in [1,2,3,1,2,3] adding the (1,2,3) in order to the array | |
The second results in [1,2,3,[1,2,3]] adding the [1,2,3] as an array within an array | |
2 SPLIT-JOIN | |
Using a combination of Array’s join method and String’s split method, | |
write a single Ruby expression that converts [1,2,3] into ["1", "2", "3"]. | |
#This one is a little difficult, you have to call to methods to the array, | |
#keep in mind that what you call on the first method, you have to call on the second | |
2a [1,2,3].join(“”).split(“”) | |
3 REDUCE, REUSE, RECYCLE | |
Based on your understanding of how Symbols work, what do you think the Array | |
Symbol.all_symbols represents? How do you add a new Symbol to this Array? | |
#Don't think too hard on this one. Complete the first step first, then do the second separately | |
3a Symbol.all_symbols represents all recycled symbols in Ruby. | |
:mario adds the new symbol | |
first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment