Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4023

Re: Lets play a guessing game. (how to code this better?)

From Super Goat <ruby-forum@sgoat.33mail.com>
Newsgroups comp.lang.ruby
Subject Re: Lets play a guessing game. (how to code this better?)
Date 2011-05-06 01:18 -0500
Organization Service de news de lacave.net
Message-ID <b38c8af4585da663e93ac2f2facf10df@ruby-forum.com> (permalink)
References <60cd2d7685f4d805fa7b7b953b5667d5@ruby-forum.com>

Show all headers | View raw


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/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Lets play a guessing game. (how to code this better?) Super Goat <ruby-forum@sgoat.33mail.com> - 2011-05-05 01:45 -0500
  Re: Lets play a guessing game. (how to code this better?) Stu <stu@rubyprogrammer.net> - 2011-05-05 02:28 -0500
  Re: Lets play a guessing game. (how to code this better?) Josh Cheek <josh.cheek@gmail.com> - 2011-05-05 02:51 -0500
  Re: Lets play a guessing game. (how to code this better?) John Feminella <johnf@bitsbuilder.com> - 2011-05-05 03:10 -0500
    Re: Lets play a guessing game. (how to code this better?) Johannes Held <johannes.held@informatik.uni-erlangen.de> - 2011-05-06 10:51 +0200
      Re: Lets play a guessing game. (how to code this better?) Johnny Morrice <spoon@killersmurf.com> - 2011-05-06 07:01 -0500
        Re: Lets play a guessing game. (how to code this better?) Johnny Morrice <spoon@killersmurf.com> - 2011-05-06 07:04 -0500
        Re: Lets play a guessing game. (how to code this better?) Johannes Held <johannes.held@informatik.uni-erlangen.de> - 2011-05-06 14:13 +0200
          Re: Lets play a guessing game. (how to code this better?) Johnny Morrice <spoon@killersmurf.com> - 2011-05-06 07:23 -0500
  Re: Lets play a guessing game. (how to code this better?) Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-05 03:56 -0500
  Re: Lets play a guessing game. (how to code this better?) Martin Boese <boesemar@gmx.de> - 2011-05-05 10:32 -0500
  Re: Lets play a guessing game. (how to code this better?) Super Goat <ruby-forum@sgoat.33mail.com> - 2011-05-06 01:18 -0500
    Re: Lets play a guessing game. (how to code this better?) Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-06 02:27 -0500
    Re: Lets play a guessing game. (how to code this better?) Josh Cheek <josh.cheek@gmail.com> - 2011-05-06 02:34 -0500
  Re: Lets play a guessing game. (how to code this better?) Super Goat <ruby-forum@sgoat.33mail.com> - 2011-05-08 00:08 -0500
    Re: Lets play a guessing game. (how to code this better?) Josh Cheek <josh.cheek@gmail.com> - 2011-05-08 00:30 -0500
    Re: Lets play a guessing game. (how to code this better?) Stu <stu@rubyprogrammer.net> - 2011-05-08 01:16 -0500
      Re: Lets play a guessing game. (how to code this better?) Stu <stu@rubyprogrammer.net> - 2011-05-08 02:22 -0500
        Re: Lets play a guessing game. (how to code this better?) Super Goat <ruby-forum@sgoat.33mail.com> - 2011-05-08 21:20 -0500
          Re: Lets play a guessing game. (how to code this better?) Stu <stu@rubyprogrammer.net> - 2011-05-09 00:29 -0500

csiph-web