From: Will Mueller Date: 2008-04-21T07:14:24+09:00 Subject: Re: Counting Program Thanks, that worked. On Sun, Apr 20, 2008 at 4:33 PM, Phillip Gawlowski wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > Will Mueller wrote: > > | time1=1 > | 10000000.times do > | puts time1+1 > | end > | > | All it would do, is simply print out the number 2, 10000000 times. I > | continually got errors when editing it. Could someone please assist? > > Well, it's as simple as adding a '=': > > > time1 = 1 > 10000000.times do > ~ time1 += 1 # this is shorthand for time1 = time1 + 1 > ~ puts time1 > end > > You need to tell Ruby, that you want to change the variable explicitly. > > A quote I cannot attribute: "Computers never do what they should, only > what you tell them to do". ;) > > It might help if you put spaces between operators, as that helps in > catching errors. I am speaking from experience. > > - -- > Phillip Gawlowski > Twitter: twitter.com/cynicalryan > > ~ "That's the whole problem with science. You've got a bunch of > ~ empiricists trying to describe things of unimaginable wonder." > ~ --- Calvin > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkgLtsIACgkQbtAgaoJTgL/rYQCgkPvb3NX47KpkP+6uXdvxpGws > Tn8AnAqS0RyN0aa2t3QPvxNem58Bi/bj > =AFlL > -----END PGP SIGNATURE----- > > -- Will M wce.page.tl freetechtips.tk will.liljon@gmail.com