Just a newbie



Hello all. Sorry for bothering you. I am trying to learn Ruby. i just wrote these codes and i am pretty sure i did all right but i still got this error. I just want to know what is my mistake.

( I passed lesson someway prob logic is ok )

How old are you?undefined local variable or method `get' for # < Context:0xf219e4>

print "How old are you?"
user_num = Integer(get.chomp)

if  user_num < 15
    puts "You are still a child"
else user_num > 15 
    puts "You are a man!"


It should be get string as in, gets.chomp.


Before this lesson editor gave an example. it was like

print "Integer:"
user_num = Integer(get.chomp)

if user_num < 0
puts" It is negative" something like this i just copied that lines
(couldnt access that lesson that's why cant copy paste)

but even if change chomp to string still giving error.


user_num = Integer(get.chomp)
undefined local variable or method `get' for #<Context:0x52c9c0>

user_num = Integer(gets.chomp)


Thank you and really sorry for bothering you (so simple mistake)


You're welcome. No need to apologize. We all make mistakes, and many of them are face-palmers. It's only human.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.