view · edit · sidebar · attach · print · history

Ruby Simple string vs EOS

<< CompileOptiosfor19 | Index | Eval >>

## simple string ##
a = "abc\ndef\n"

## EOF ##
b =<<-EOF

p a
p b



Sample code in ODBA

Also see:

Strings can continue across multiple input lines, in which case they will contain newline characters. It is also possible to
use here documents to express long string literals. Whenever Ruby parses the sequence <<identifier or <<quoted string, it
replaces it with a string literal built from successive logical input lines. It stops building the string when it finds a
line that starts with the identifier or the quoted string. You can put a minus sign immediately after the << characters, in
which case the terminator can be indented from the left margin. If a quoted string was used to specify the terminator, its
quoting rules will be applied to the here document; otherwise, double-quoting rules apply.

view · edit · sidebar · attach · print · history
Page last modified on March 15, 2011, at 09:13 AM