RubyCademy
Published in

RubyCademy

Avoid interpolation in heredoc

Heredoc with interpolation

venue = "world"str = <<-EOF
I'm the master of the #{venue} !\n
No you're dead bro..
EOF
I'm the master of the world !No you're dead bro..

Heredoc without interpolation

venue = "world"str = <<-'EOF'
I'm the master of the #{venue} !
No you're dead bro..\n
EOF
I'm the master of the #{venue} !
No you're dead bro..\n

Misc

<<-SQL
SELECT id
FROM table
WHERE
id IS NOT NULL AND id > 200
ORDER BY
id DESC;
SQL
Thank you for your support! 😉

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store