To my list of Ruby achievements, I can now add the dubious distinction of having come up with the syntax for the new “squiggly heredoc” introduced in version 2.3. Thus playing my part in making the Ruby grammar just a little bit more chaotic.
For reference, the syntax looks like this:
JABBERWOCKY = <<~EOF
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
-- From "jabberwocky", by Lewis Carroll
Using this syntax intelligently strips indent from the quoted string, as explained in this blog post by Damir Svrtan.
As I recall, the syntax I suggested for that feature was more or less the first thing that popped into my head. That said, it wasn’t a completely arbitrary choice. There’s a mnemonic reason for it, that I figure I probably ought share now that it’s an official Ruby feature.
The mnemonic is this: the text quoted by a squiggly heredoc is squished, or more accurately the leading whitespace is squished, over to the left margin. Thus, the syntax is that of a “dashed heredoc”, except that the dash has been squished as well, leaving it “squiggly”.
I guess I should have called it the “squished heredoc” when I suggested it.