Skip to content

Instantly share code, notes, and snippets.

@iwazer
Created August 11, 2011 04:44
Show Gist options
  • Save iwazer/1138923 to your computer and use it in GitHub Desktop.
Save iwazer/1138923 to your computer and use it in GitHub Desktop.
Rubyで配列から変数へ値を取り出す
# http://twitter.com/#!/yuroyoro/status/101510384883728385
k,*v = [1,2,3]
#k => 1
#v => [2,3]
x,y,*v = [1,2,3,4]
#x => 1
#y => 2
#v => [3,4]
x,*v,y = [1,2,3,4]
#x => 1
#v => [2,3]
#y => 4
*v,x,y = [1,2,3,4]
#v => [1,2]
#x => 3
#y => 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment