From: Florian Gilcher Date: 2012-01-31T21:24:33+09:00 Subject: Re: why we need heredoc On Jan 31, 2012, at 1:00 PM, Lucky Nl wrote: > In ruby we have the concpet "heredoc" to handle multiple line strings > > > We can handle that with doublequotes > for example > x = "Grocery list > ------------ > 1. Salad mix. > 2. Strawberries. > 3. Cereal. > 4. Milk. > " > > puts x > > OUTPUT: > Grocery list > ------------ > 1. Salad mix. > 2. Strawberries. > 3. Cereal. > 4. Milk. > > Anyspecific reason to use heredoc concept We don't exactly "need it", but its nice to have around. Heredoc has some special properties that can come in handy if you are using long literal strings in argument lists. For example, you can begin a Heredoc in an argument list and continue after the list is closed: foo('test', <<-HERE, 'test') THIS IS A LINE AND A SECOND HERE Taken to the extreme, you can use 3 Heredocs: foo(<<-FIRST, <<-SECOND, <<-THIRD) my first text FIRST my second text SECOND my third text THIRD Regards, Florian