P$HRAŁK
December 15th, 2007, 02:05 PM
I'm new to Ruby but its pretty much accurate to say I've fallen in love with it :rolleyes:
Anyway, I'm trying a very very simple user input program with the gets method. Problem is, I keep getting an error when in IRB which tells me that the line of code I've indicated with **********, can't be done because "String can't be coerced into fixnum". I've converted the year variable into an integer value and the same for the age variable, and I've converted the final product back into a string for the final "puts" output, so whats going wrong?
puts "What is your name?"
name = gets.chomp
puts "How old are you?"
age = gets.chomp
age.to_i
year = 2007
year =- age**********
year.to_s
puts name + " was born in " + year
Anyway, I'm trying a very very simple user input program with the gets method. Problem is, I keep getting an error when in IRB which tells me that the line of code I've indicated with **********, can't be done because "String can't be coerced into fixnum". I've converted the year variable into an integer value and the same for the age variable, and I've converted the final product back into a string for the final "puts" output, so whats going wrong?
puts "What is your name?"
name = gets.chomp
puts "How old are you?"
age = gets.chomp
age.to_i
year = 2007
year =- age**********
year.to_s
puts name + " was born in " + year