[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Semantics of << and <<-
From: "William James" <w_a_x_man () yahoo ! com>
Date: 2005-08-31 23:26:24
Message-ID: 1125530654.984280.78270 () g14g2000cwa ! googlegroups ! com
[Download RAW message or body]
Anders Höckersten wrote:
> Hi,
> I recently joined this list, so please forgive me if this question has
> been asked recently. I am wondering about the precise semantics of <<
> and <<-. "Programming Ruby"[1] and the pseudo-BNFs[2][3] say that you
> can use a quoted string after <<. As I see it, this means I should be
> able to able to use the #{expr} construct inside this string, like this:
> print <<"#{2+2}"
> foobar
> #{4}
The purpose of quoting the here-document label is to make the
text be treated as though it were enclosed in single quotes.
----------------------------------------------
puts <<'HERE'
#{3**3} bells.
HERE
puts <<"HERE"
#{3**3} bells.
HERE
puts <<HERE
#{3**3} bells.
HERE
------------------------------------------------
#{3**3} bells.
27 bells.
27 bells.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic