From: Luca Pireddu Date: 2005-05-21T03:15:15+09:00 Subject: Re: Multiple return and parallel assignement David A. Black wrote: > Hi -- > > On Sat, 21 May 2005, Eric Mahurin wrote: > > > It's hard, I find, to come up with an exact description of what the > unarr?ay (unary unarray) operator does that fits every case. The > closest I've come is: *a = x means: a gets assigned that which, when > stripped of one level of array-ness, is x. Thus: > > *a = 1,2 # [1,2] stripped of [] is 1,2 so a is [1,2] > *a = *[1,2] # a stripped of [] is [1,2] stripped of [], so > # a is [1,2] > > def x(*args); end > x(1,2,3) # [1,2,3] stripped of [] is 1,2,3, so args is [1,2,3] > x([1,2,3]) # [[1,2,3]] stripped of [] is [1,2,3], so args > # is [[1,2,3]] > > Then there's > > a = 1,2 # automatic arraying -- the opposite of * > a = *[1,2] # un-arraying followed by automatic arraying :-) > > or something like that. > > > David > Maybe a simpler way to look at it is *a = x means a = [x], or simply enclose the rhs in an array before assignment. Luca