For non-rubyists, what does this example do? Are those labels?
<<-END
this is some text
END
will give you a string containing " this is some text\n". END can be anything.It's particularly useful in metaprogramming, since you can maintain formatting, and you don't have to escape " or ' if they happen to show up in your code.
What's interesting in the OP's example is that you end up passing three strings " text of one\n", " text of two\n", " text of three\n". I had no idea that would happen, though I have seen things like
define_method <<-RUBY, __FILE__, __LINE__ + 1
some_code
RUBY
so it makes sense. Ruby treats anything on the same line after the comma as separate arguments, so even though __FILE__ comes after <<-RUBY and before RUBY, it really appears after the final RUBY to the interpreter.I had no idea it could be nested like that and I've been using ruby for 8 years. Crazy!
Some days I wish Matz would formalize the grammar so it is sane.