"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

···

--
Posted via http://www.ruby-forum.com/.

The control flow word is spelled "if".

Kind regards

robert

···

On Fri, Sep 7, 2012 at 10:18 AM, Mattias A. <lists@ruby-forum.com> wrote:

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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

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

···

--
Posted via http://www.ruby-forum.com/.

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.

···

On Fri, Sep 7, 2012 at 3:18 AM, Mattias A. <lists@ruby-forum.com> wrote:

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

Thanks very much for your input josh-cheek!

···

--
Posted via http://www.ruby-forum.com/.

We all went through this... :slight_smile:

Kind regards

robert

···

On Fri, Sep 7, 2012 at 10:33 AM, Mattias A. <lists@ruby-forum.com> wrote:

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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

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

···

On Fri, Sep 7, 2012 at 5:11 PM, Robert Klemme <shortcutter@googlemail.com>wrote:

On Fri, Sep 7, 2012 at 10:33 AM, Mattias A. <lists@ruby-forum.com> wrote:
> Ahhh.. Its not easy to be a beginner... :stuck_out_tongue: Thanks robert!!!

We all went through this... :slight_smile:

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/