From: Randy Coulman Date: 2012-02-09T06:24:33+09:00 Subject: Re: Require bug confirmation: possible 'times' method error --20cf30050c964563a904b87a85d2 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable No problem. I wasn't trying to be cryptic, and maybe I've been helping my kids with their homework too much lately, but I wanted to give you some hints that would lead you to discover the answer for yourself. I find I learn better if I have to figure some things out for myself, as long as I don't get frustrated by being stuck on something for too long. Randy On Wed, Feb 8, 2012 at 10:50 AM, Tom Clarke wrote: > Hi, > > I realised what Randy was trying to say about 5 minutes after I stepped > away from my computer (I often think best away from it). Apologies for > being short with you Randy, I understand what you were trying to say now.= , > thank you for your help > > Thank you to Ian and Matma for your explanations also. > > Cheers, > Tom > > 2012/2/8 Bartosz Dziewo=F1ski > > > Calling num.times{|i| ...} counts from 0 to num-1, *not* from 1 to num. > > > > Therefore, using 6 here will never trigger the condition (since 5 is > > not greater than 5), the explicit return will not be used, and the > > method will return the value of last expression. This expression is > > the #times block, and #times returns the receiver (ie., the number it > > was called on) - in this case, 6. Then the multiple assignment will > > assign 6 to first variable, and nil to the second one. > > > > -- Matma Rex > > > > > --=20 Randy Coulman rcoulman@gmail.com Twitter: @randycoulman --20cf30050c964563a904b87a85d2--