From: Andrew McGuinness Date: 2006-01-13T07:13:06+09:00 Subject: Re: Newbie question about multiple assignments David Vallner wrote: > On Thu, 12 Jan 2006 15:09:01 +0100, wrote: > >> >> An assignment expression returns its right-hand side. In this case, >> that's [b, a = a, b]: >> >> a = 1 >> b = 2 >> [b, a = a, b] => [2,1,2] >> > > > Ah well, for some strange reason I thought the parser would check for a > parallel assignment form inside the array constructor as well. > Apparently not... Right, that example pretty much clears the issue up. > Within method arguments, the "," gets parsed as an argument separator not an array separator: irb(main):094:0> puts( a,b = 1,2 ) 1 1 2 => nil irb(main):095:0> puts( ( a,b = 1,2 ) ) 1 2 => nil irb(main):103:0> a,b=1,2 => [1, 2] irb(main):104:0> a,b=(b,a=a,b) => [1, 2] irb(main):105:0> a => 1 irb(main):106:0> b => 2