This is the ideal Ruby syntax. You may not like it, but this what peak performance looks like.

@jared You didn't give us a tricky case where it didn't interpolate, and you got hideous mis-syntax?

That's wonderfully hideous, though.

I use multiple heredocs in a single line routinely to put test-app code and test code together. But never nested heredocs. Guess it's time to find a use for them! 😈

@codefolio I'm not that devious! These are definitely interpolating "as expected".

I'm glad you posted it on Mastodon too @jared! There's enough room for me to explain my reasoning here.

Based on the docs (https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-Here+Document+Literals) and some experimentation, I think it's this.

PLEASE is opened and closed within OH_NO.
`concat` executes at the end of OH_NO and opens JARED_STOP.
That leaves the first and last line only in DO_CRIME.

But do you know the actual answer or how to find it?

literals - Documentation for Ruby 3.4

@ChaelCodes Yes, you have it right! 💪

Here's a version where I've added annotations to make it more clear, the output… and then an image I just made that shows the same thing yours does.

I admittedly hadn't tried to figure out what was going on until you asked. I think the right way would probably be to run it through RubyConf doublRubyConf

Credit Kevin Newton for the idea. I overheard him talking about an issue with nested heredocs at lunch at RubyConf and I couldn't help myself.

@jared

✨ Magical! ✨

@jared this syntax is lovely it’s the editor that is flawed.
@austinfromboston I think the only thing that could make this readable for the average person is to colourize the strings to match the tokens they correspond to, which would be cool.
@jared I think a bit of outdenting would be a big improvement