Skip to content

Instantly share code, notes, and snippets.

@nbatalla03
Created August 15, 2013 13:02
Show Gist options
  • Save nbatalla03/6240649 to your computer and use it in GitHub Desktop.
Save nbatalla03/6240649 to your computer and use it in GitHub Desktop.
#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