Created
January 6, 2012 19:46
-
-
Save gdiggs/1572069 to your computer and use it in GitHub Desktop.
Adding/moving item to the front of an array
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
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