Skip to content

Instantly share code, notes, and snippets.

@ersatzryan
Created May 19, 2011 14:48
Show Gist options
  • Save ersatzryan/980917 to your computer and use it in GitHub Desktop.
Save ersatzryan/980917 to your computer and use it in GitHub Desktop.
Array slice weirdness
a = (1..10).map.reverse #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Array(a).unshift(11).slice(0, 10) #=> [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
a = Array(a).unshift(11).slice(0, 10) #=> [11, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment