Skip to content

Instantly share code, notes, and snippets.

@toothrot
Created June 25, 2010 18:28
Show Gist options
  • Save toothrot/453238 to your computer and use it in GitHub Desktop.
Save toothrot/453238 to your computer and use it in GitHub Desktop.
# via jaknowlden:
irb(main):001:0> (k, v), *rest = [[1,2], [3,4], [5,6]]
=> [[1, 2], [3, 4], [5, 6]]
irb(main):002:0> k
=> 1
irb(main):003:0> v
=> 2
irb(main):004:0> rest
=> [[3, 4], [5, 6]]
@toothrot
Copy link
Author

oh, nice.

@evanfarrar
Copy link

stupid formatting erased my splat, i was just showing that you can use another splat inside

    (a,*b),*c = [[1,2,3],[3,4,5]] => [[1, 2, 3], [3, 4, 5]]

then you will get the same result as me

@thumblemonks
Copy link

*["Nope", "Too late", "Not trying now"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment