Austin Ziegler wrote:
> On 8/15/06, Peter Bailey <pbailey / bna.com> wrote:
>> Thanks, James. Sorry 'bout Ruby. I don't understand why my pound sign is
>> a comment starter there, but, it's not prior to that in the same line.
>> Isn't that a legitimate pointer to a variable, #{psfile} ?
> 
> No. There's no such thing as a pointer to a variable in Ruby; Ruby
> variables don't work that way (thank ghu). The construct #{var} is
> used for interpolation, but only in regular expression and quoted
> string constructs. That means it can be used with %r{#{var}},
> /#{var}/, "#{var}", %Q{#{var}}, %W{#{var}}, and heredocs with
> interpolation (<<-"EOS" instead of <<-'EOS').
> 
> The #{} interpolation does not even have to be a variable. I could do:
> 
>   puts "2 + 2 = #{2 + 2}"
> 
> Any legal expression may be in the interpolation, but it may cause
> your syntax highlighting routines in your editor some grief if you get
> too complex there. Some things do not need the braces, such as global
> variables (#$LOAD_PATH) or instance variables (#@inst_var). When
> you're not in an interpolative mode, if you use the #{} (or #$ or #@)
> you will simply get a commented rest of the line.
> 
> -austin


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.

-- 
Posted via http://www.ruby-forum.com/.