Matthew Lindfield Seager

Matthew Lindfield Seager

Multiple assignment from array in Ruby:

a, b = 1, 2 # a == 1, b == 2
c, d = [3, 4] # c == 3, d == 4
e, f = '5 6 7'.split # e == 5, f == 6, 7 is ignored(?)
g, h, i = 'foo_bar'.split('_') # g == 'foo', h == 'bar', i is nil