0

I wonder how can I preserve consecutive newline characters with Ruby here-document? In my program all of them are collapsed to one newline. For example:

s=<<END
1
2

3


4



END

evaluates to:

s="1\n2\n3\n4\n"

However I would like to preserve the consecutive newlines when for example formatting a BBcode document a letter or something similar.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Konstantin
  • 2,983
  • 3
  • 33
  • 55

1 Answers1

0

That looks like a bug to me. Have you tried a multiline %q?

s=%q(1
2

3


4



)
Hew Wolff
  • 1,489
  • 8
  • 17