Turn ruby heredocs from double-quoted into sinqle-quoted strings

May 17, 2009 by Michael

By default, Rubys heredocs are interpreted as double-quoted strings, that is #{something} is evaluated, \r turns into newline and so forth.

You can change this behaviour by single quoting the heredoc identifier like so:

s = <<-'SINGLE_QUOTED'
#{i'm not interpreted}
SINGLE_QUOTED

No comments yet

Post a Comment

Your email is never published nor shared. Required fields are marked *