"Guess the random number" game

Hi guys!

I am new to programing and need some help. I have decided to try doing a
“Guess the random number” program. When i try to run below its fails on
keyword_else? But i dont understand why, can some body help me? Thanks
in advance.

print “Guess a number between 0-10\n”

puts “Enter your guess:”
GuessNumber = gets.to_i

Number = rand(10)

If GuessNumber < Number then
puts “Too Loo”
else
puts “Too High”
end

On Fri, Sep 7, 2012 at 10:18 AM, Mattias A. [email protected]
wrote:

puts “Enter your guess:”
GuessNumber = gets.to_i

Number = rand(10)

If GuessNumber < Number then
puts “Too Loo”
else
puts “Too High”
end

The control flow word is spelled “if”.

Kind regards

robert

Ahhh… Its not easy to be a beginner… :stuck_out_tongue: Thanks robert!!!

On Fri, Sep 7, 2012 at 10:33 AM, Mattias A. [email protected]
wrote:

Ahhh… Its not easy to be a beginner… :stuck_out_tongue: Thanks robert!!!

We all went through this… :slight_smile:

Kind regards

robert

On Fri, Sep 7, 2012 at 3:18 AM, Mattias A. [email protected] wrote:

puts “Enter your guess:”

Also, use lowercase variable names (by convention, Rubyists also
snake_case
them) because variables beginning with capital letters are constants,
and
will behave differently. And for your own sanity, you’re going to want
to
indent when you go into the if statements.

Wow, Robert. I appreciate your humbleness. Not all seasoned programmers
are
like you.

Thanks very much for your input josh-cheek!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs