From: David Vallner Date: 2006-01-12T21:49:44+09:00 Subject: Re: Newbie question about multiple assignments On Thu, 12 Jan 2006 13:39:00 +0100, Michael Ulm wrote: > Alex wrote: >> irb(main):091:0> a=1 >> => 1 >> irb(main):092:0> b=2 >> => 2 >> irb(main):093:0> a,b=b,a >> => [2, 1] >> irb(main):094:0> a=1 >> => 1 >> irb(main):095:0> b=2 >> => 2 >> irb(main):096:0> a, b = b, a = a, b >> => [2, 1, 2] <-- Why? >> What is the order for the assignments >> > > Keep in mind, that > > a, b = c, d > > is just shorthand for > > a, b = [c, d] > > So, your expression > > a, b = b, a = a, b > > gets parsed as > > a, b = [b, a = a, b] > > and thus produces the observed behaviour. > > HTH, > > Michael > > That doesn't seem to explain the return value [2, 1, 2] of the expression. David Vallner