Created
August 15, 2013 13:02
-
-
Save nbatalla03/6240649 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#Using negative element selector | |
array = [1,2,3] | |
array[-1] + array[-2] | |
#Using pop and last. | |
#It appears pop and last do the same thing so you can switch them out, I'm using pop. | |
array = [1,2,3].pop(2) | |
array.reduce(:+) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment