From: Mike Austin <"mike[nospam]"@...> Date: 2008-11-19T10:36:42+09:00 Subject: Re: Syntax question from a newbie to Ruby David Spitzer wrote: > John W Kennedy wrote: >> David Spitzer wrote: >>> puts 'Hello what is you\'re Favorite Number?' >> Well, there's your /first/ syntax error. >> >>> puts 'I think ' + (number.to_i + 1) + ' may be a better favorite number >>> though...' >> Since "+" can mean either "concatenate strings" or "add numbers", you >> need a "to_s" there, just as you needed "to_i" before trying arithmetic. >> -- >> John W. Kennedy >> "Though a Rothschild you may be >> In your own capacity, >> As a Company you've come to utter sorrow-- >> But the Liquidators say, >> 'Never mind--you needn't pay,' >> So you start another company to-morrow!" >> -- Sir William S. Gilbert. "Utopia Limited" > > Aha it worked!: > > puts 'I think ' + (number.to_i + 1).to_s + ' may be a better favorite > number though...' > > thanks! I don't see use of Ruby's streams used much in examples: $stdout << "I think " << number + 1 << " may be a better favorite\n" It's much cleaner, although not as simple a concept as print. Mike