Skip to content

Instantly share code, notes, and snippets.

@gdiggs
Created January 6, 2012 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdiggs/1572069 to your computer and use it in GitHub Desktop.
Save gdiggs/1572069 to your computer and use it in GitHub Desktop.
Adding/moving item to the front of an array
x = 1
a = [2, 1, 4, 3]
[x] + (a - [x]) #=> [1, 2, 4, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment