Created
March 23, 2013 18:58
-
-
Save squarism/5228986 to your computer and use it in GitHub Desktop.
Delete elements from a ruby array based on index
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
# I can't believe this works this elegantly. | |
a = [1,2,3,1,3,3,7] | |
# => [1, 2, 3, 1, 3, 3, 7] | |
a.reject.with_index {|element, i| i < 3} | |
# => [1, 3, 3, 7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment