Simple code won't work


I’m obviously new to Ruby, and I can;t figure out why my code will not

print “Hello, what is your number?”
my_number = gets.to_i
print “Oh, so your number is #{my_number}, would you like me to multiply
it by 2?”
user_answer = gets.upcase

my_number * 2

puts time_to_play

It helps to put the error message, rather than saying “will not work”.
In this case it looks like your method time_to_play has some unnecessary
braces in it and has no argument. Try this:

def time_to_play( input )
input * 2

puts time_to_play( my_number )

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