From: Julian Leviston Date: 2009-02-14T14:03:10+09:00 Subject: Re: Meaning of "<<"? I thought + was for concatenation. << actually modifies Its receiver Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 14/02/2009, at 1:12 AM, saurabh purnaye wrote: > Hi Chris, > If you see the string class documentation of ruby, > http://www.ruby-doc.org/core/classes/String.html#M000822 > Its for concatenation.. > You may find more here http://www.ruby-doc.org/ > > On Fri, Feb 13, 2009 at 7:33 PM, Chris Davies >wrote: > >> Hi, >> >> I'm currently trying to learn ruby, coming from a perl/unix >> background. I've been working through one of the many online >> tutorials >> and it's suddenly thrown in the "<<" operator. >> >> Now, I'm familiar with a the use of "<<" as a bitwise left shift >> and as a here doc, but this one throws me. The relevant URL is >> http://rubylearning.com/satishtalim/ >> mutable_and_immutable_objects.html >> and here's a variation on the theme for illustrative purposes: >> >> str = 'one' >> str << 'two' >> puts str # onetwo >> >> It seems to me that << in this context is equivalent to +=, but I >> can't >> find any documentation explaining /why/ this is the case, and why I >> should use one in preference to the other. (Google really doesn't >> like >> "<<".) >> >> Any suggestions, please? >> Cheers, >> Chris >> >> > > > -- > -- > Thanks and Regards > Saurabh Purnaye > +91-9922071155 > skype: sorab_pune > yahoo & gtalk: saurabh.purnaye > msn: psaurabh@live.com