Ruby

Ruby multi-line string hell 1

Ruby multi-line string hell 1
In: Ruby

Ruby developers don't usually hate things about Ruby. But there's one thing that seems to be more complicated at times than necessary in Ruby.

Here I am again, every now and then... Those purple links...

As you can see, I'm a frequent guest at some fellow sufferers' confessions.

I even blocked the deployment once, because we didn't have tests for rake tasks and CI didn't detect that this is not a multi-line string:

logger.log "A very long sentence" /
		   "that ends here"
# => NoMethodError (undefined method `/' for "A very long sentence":String)
Can you guess what other mistake is hidden here that no one of the PR reviewers will notice? 😈 

For the IDE this syntax is just fine too, so no warnings or anything there either... 💣

Basically, every time my string got too long, I needed to look it up. I think our 80 characters line length rubocop limit was just long enough to drop off my spaced learning capabilities and force me to look it up again...

So finally, I've drawn this down as a first step to get hold of the multi-line string hell.

If you try visualizing it, the forward-slash indeed makes sense in terms of flow. The text flow after the slash will go down and not up. Here it is one more time:

No more purple links! For that part at least. There's some more visualization and meditation needed to get the rest of it into my brain, so that the devious Heredoc interpolations, squiggly operators, and whitespace handlers become second nature.

Comments
More from RichStone Input Output
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to RichStone Input Output.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.