From: James Edward Gray II Date: 2006-08-15T23:34:40+09:00 Subject: Re: Trouble parsing against a hash On Aug 15, 2006, at 9:18 AM, Peter Bailey wrote: > James Gray wrote: >> On Aug 15, 2006, at 8:14 AM, Peter Bailey wrote: >> >>> You mean, it's because I was simply missing quotes around my "#{}" >>> expression that it was regarded as a comment? Well, I guess I can >>> certainly understand that. Thanks a lot. >> >> Right. But never use: >> >> "#{var}" >> >> because that's just a confusing way to say: >> >> var.to_s >> >> And if the variable is already a String, you really just want: >> >> var >> >> James Edward Gray II > > OK. I'm a bit confused, though. I've been using #{var} for quite a > while > now. I thought it was needed when getting a variable within a > block. Is > it when it's in double quotes that you suggest not using it? As we have said, #{ .. } is only used inside double-quoted Strings. You don't need it anywhere else. You use it to interpolate some value into a String. For example: "1 + 2 = #{1 + 2}" or: var = 2 "1, #{var}, 3, ..." When used like that, you are fine. That's what it's for. However, if you ever type *just* that it a String, you didn't need the String: "#{var}" # => same as var.to_s or just var, if it is a String Hope that makes more sense. James Edward Gray II