From: Gregor Kopp Date: 2006-02-28T23:48:36+09:00 Subject: Re: Pine's book "Learning to Program" - Answer? Try also this to get the feel how it works: num = "1" puts 'puts "num"' puts "num" puts 'puts num' puts num puts 'puts "#{num}"' puts "#{num}" Gregor Kopp schrieb: > 1.) if you do a .to_i to num, you dont need to chomp it. > 2.) if you make 'num'.to_i you try to transform the string num into > integer. it should be num.to_i, because you want the value of num and > not "num". > 3.) #{expression} in string will be replaced with its value in that string. > try > > (1..10).each do |number| > puts "Hallo there, Number #{number}!" > end > > hope that helped ;) > > sorry about my english, i know it sucks alot! > > > woodyee schrieb: > >> Hi! I'm stuck on Chapter 5, 5.4: >> >> "Write a program which asks for a person's favorite number. Have your >> program add one to the number, then suggest the result as a bigger and >> better favorite number. (Do be tactful about it, though.)". >> >> Any ideas? I'm getting "can't convert fixnum into string" errors. >> Here's one of the many things I've tried, er, failed: >> >> puts 'What is your favorite number ?' >> num = gets.chomp >> better = 'num'.to_i + 1 >> puts 'This is better: ' + better + '.' >> >> 3rd line's getting me. Can't figure out how to add 1 to the response. >> Hopefully, I'll figure this out but any tips are welcomed. Thanks! >>