On May 2, 2004, at 10:00 PM, Richard Lionheart wrote:

> As I read Thomas&Hunt p. 205,  Ruby should build a quoted string with 
> the
> text from <<XXX to the next XXX.  But that doesn't happen with some 
> quoted
> strings in that block,  as follows.  Why?

In a normal heredoc, you can do variable interpolation:

   a = "foo"
     => "foo"
   str = <<TEXT
   text #{a} here
   TEXT
     => "text foo here\n"

You can get around this in two ways. One, mentioned by a previous 
poster, is to escape the interpolation:

   str = <<TEXT
   text \#{a} here
   TEXT
     => "text #{a} here\n"

Another way, if you aren't going to need interpolation in that 
particular string, is to use a non-interpolated heredoc:

   str = <<'TEXT'
   text #{a} here
   TEXT
     => "text #{a} here\n"

Single quotes around the heredoc word will make it non-interpolated.

HTH,
--Mark