From: Chad Perrin Date: 2007-03-04T14:20:41+09:00 Subject: Re: Programming Ruby book p.50 (Fibonacci yield example) On Sun, Mar 04, 2007 at 02:34:00AM +0900, Gary Wright wrote: > > On Mar 3, 2007, at 12:13 PM, Mike Glaz wrote: > >5. i1, i2=i2, i1+i2 > [...] > >But I have no clue what is happenening in line 5. > > The spacing in your text is a bit misleading. > This makes it a little clearer: > > i1,i2 = i2,(i1+i2) > > This is Ruby's multiple assignment statement. The > expressions on the right are evaluated into a list and > assigned, in order, to the variables on the left. I probably would have done it thusly: i1, i2 = i2, i1 + i2 . . . or: i1, i2 = [i2, i1 + i2] . . . or something to that effect. Somehow, it seems more readable to me. YMMV. Do my versions for any particular reason seem unlike the typical Ruby idiom for some reason? I'm curious. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "There comes a time in the history of any project when it becomes necessary to shoot the engineers and begin production." - MacUser, November 1990