From: Austin Ziegler Date: 2006-08-15T22:07:34+09:00 Subject: Re: Trouble parsing against a hash On 8/15/06, Peter Bailey 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 -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca