News for hackers. Stuff that matters.
Re:Zed Shaw: The wonderful Rob Sobers did a great job transl... by GaltMidas on Thursday August 04, 2011 @04:31PM (#2847621)
Couldn't get your way to work, it blew off the rest of the string. Managed to get it to work by calling .to_s on each variable. Wondering if I did something wrong. I have your same setup and I'm a complete Ruby Noob.
Re:Zed Shaw: The wonderful Rob Sobers did a great job transl... by reaganing on Thursday August 04, 2011 @04:37PM (#2847648)
to be clear, my line 10 looks like this:

puts "There are #{cars} cars available."

But, yeah, complete Ruby noob here as well so I don't really know what's wrong.

Re:Zed Shaw: The wonderful Rob Sobers did a great job transl... by danso on Thursday August 04, 2011 @04:48PM (#2847695)
>10 puts "There are " + cars + " cars available."

Yes, this will throw an error in Ruby because of line 1:

>1 cars = 100

Ruby does not allow the mixing of integers and strings. So, as mentioned, you can invoke the .to_s method. Or you can interpolate the variables as you have done so with #{cars} inside double quotes.

Re:Zed Shaw: The wonderful Rob Sobers did a great job transl... by grossvogel on Thursday August 04, 2011 @05:15PM (#2847813)
When I read exercise 4, I thought, "I can't believe Ruby made the same mistake as Javascript!" Glad to learn this particular type of foot shooting is not possible in Ruby.
Re:Zed Shaw: The wonderful Rob Sobers did a great job transl... by reaganing on Thursday August 04, 2011 @04:54PM (#2847720)
Thank you, that makes sense.
Re:Zed Shaw: The wonderful Rob Sobers did a great job transl... by getsat on Friday August 05, 2011 @06:10AM (#2849584)
Interpolation actually calls #to_s on the object, so if object.respond_to?(:to_s) returns true, you can use use it inside #{} in any kind of string that allows interpolation.