Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Super Goat Newsgroups: comp.lang.ruby Subject: Re: Lets play a guessing game. (how to code this better?) Date: Fri, 6 May 2011 01:18:51 -0500 Organization: Service de news de lacave.net Lines: 34 Message-ID: References: <60cd2d7685f4d805fa7b7b953b5667d5@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1304663361 58270 65.111.164.187 (6 May 2011 06:29:21 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 6 May 2011 06:29:21 +0000 (UTC) In-Reply-To: <60cd2d7685f4d805fa7b7b953b5667d5@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382731 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4023 Thanks everyone for taking the time to reply! The reason I had 'rand(100).to_i' and 'random.to_i' is because in IRB it told me it was a Fixnum. Also, I had just figured out why my operators weren't working so I wanted everything to be an integer. Obviously, in retrospect, I see now that I didn't have to do it that way. After I submitted to Ruby-Forum I did notice that when I was checking to see if the input was within range that it would only do this at the beginning. Putting that code in was an afterthought. I also thought that I should really check to see if it was a number but I didn't know how to do that. I was unaware that I didn't need the chomp in 'gets.chomp.to_i'. I am still trying to wrap my head around Methods. I get it, but don't know how to put down the code. Even when I look at Jesus's example I am a bit confused but I have a feeling that using Methods is a very Rubyist thing and the way Ruby was intended to be written. I really like Martin's example. I am going to try to use a Method and make this work and see if I can figure out how to reject any input that isn't a number (probably isn't hard just don't know how yet). I want to thank everyone again for their help. I definitely feel welcomed and will be back. Goat -- Posted via http://www.ruby-forum.com/.