From: nobu.nokada@... Date: 2003-11-07T12:01:21+09:00 Subject: Re: ruby-dev summary 21637-21729 Hi, At Fri, 7 Nov 2003 10:42:51 +0900, Joel VanderWerf wrote: > > In 1.8, this is concatenated at compile-time. :) > > > > s = "this is a string #{ # And you can write > > ""}that I have chosen to break #{ # comments! > > ""}into multiple lines" > > > > Very cool! It doesn't need the "", though, does it? > > irb(main):001:0> "foo#{ > irb(main):002:0" }bar" > => "foobar" It needs for compile-time concatenation, because nil.to_s might be replaced. $ ruby -rNodeDump -e '"foo#{' -e '}bar"' NodeDump V0.9 NODE_NEWLINE: [-e:1] NODE_DSTR: "foo" NODE_EVSTR: NODE_STR: "bar" $ ruby -rNodeDump -e '"foo#{' -e '""}bar"' NodeDump V0.9 NODE_NEWLINE: [-e:1] NODE_STR: "foobar" This optimization is limited to the case #{} ends with a literal string (and preceding literals without any side effects) -- Nobu Nakada