From: Harry Kakueki Date: 2007-06-07T11:04:46+09:00 Subject: Re: Globals not incrementing inside block On 6/7/07, Todd A. Jacobs wrote: > > I assumed I had to use globals, since otherwise the block would treat > the counters as local variables, but I have the same problem either way: > the counters never increase. They still both read zero at the end of the > script, even though some strategic puts statements show that the file is > successfully being read. > > What newbie mistake am I making now? > > -- > "Oh, look: rocks!" > -- Doctor Who, "Destiny of the Daleks" > > You don't need global variables. total = 0 5.times do total += 1 end p total # 5 Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/