7stud -- wrote:
> Fredrik Ludvigsen wrote:
>> Would anyone care to explain what happens when the following is
>> executed? (I already know what gets printed, but not why...)
>>
>> print <<-STRING1, <<-STRING2
>>   Concat
>>   STRING1
>>     enate
>>     STRING2
>>
>>
>> I'm sorry if it has been answered before, but I didn't know just what to
>> search for in the forum...
>>
>> Thanks in advance :-)
> 
> 1) Knowing what that code does will not make you a better ruby 
> programmer.
> 
> 2) You should never use such a construct in your own code.
> 
> If that code is from some tricky quiz question that you have to answer, 
> then ok.  But you can safely forget all about that construct the 
> momement you are done answering the question.  What that prints is 
> totally irrelevant.

Is there a valid reason not to use something like:

print <<-Stop
   #{a+b}
   Stop

or the version posted by the OP?  Compared to some of the other code I 
see in Ruby this seems fairly easy to understand once I experimented 
with it.