String literals

Hello,

I’m not very experienced in ruby, and can’t found how to write long
multiline string literals without variable expanding. I know that I
can use:

"literal"
'literal'
%Q{literal}
%q{litaral}
var = <<EOF
...
EOF

but the last one, multiline, is there only in “” (expanding) variant.
Is there unexpanding (’’) variant of the multiline string literal.

···


Radek Hnilica

No matter how far down the wrong road you’ve gone, turn back.
Turkish proverb

but the last one, multiline, is there only in "" (expanding) variant.
Is there unexpanding ('') variant of the multiline string literal.

Something like this ? (see '' around EOF)

pigeon% cat b.rb
#!/usr/bin/ruby
$a = 12
var = <<'EOF'
variable #$a
EOF
p var
pigeon%

pigeon% b.rb
"variable #$a\n"
pigeon%

Guy Decoux

str = 'First line. ’
+ ‘Second line.’
+ ‘Third line.’

Hope this helps.

Cheers,
Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

···

On Tue, 14 Jan 2003, Radek Hnilica wrote:

Hello,

I’m not very experienced in ruby, and can’t found how to write long
multiline string literals without variable expanding. I know that I
can use:

“literal”
‘literal’
%Q{literal}
%q{litaral}
var = <<EOF

EOF

but the last one, multiline, is there only in “” (expanding) variant.
Is there unexpanding (‘’) variant of the multiline string literal.


Radek Hnilica

No matter how far down the wrong road you’ve gone, turn back.
Turkish proverb

Don’t forget that with %Q and %q you can use any non-alphanum char as the start-end delimiter %^^ # => ""

···

Radek Hnilica (Radek@Hnilica.CZ) wrote:

Hello,

I’m not very experienced in ruby, and can’t found how to write long
multiline string literals without variable expanding. I know that I
can use:

“literal”
‘literal’
%Q{literal}
%q{litaral}
var = <<EOF

EOF

but the last one, multiline, is there only in “” (expanding) variant.
Is there unexpanding (‘’) variant of the multiline string literal.


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

ts wrote:

“R” == Radek Hnilica Radek@Hnilica.CZ writes:

but the last one, multiline, is there only in “” (expanding) variant.
Is there unexpanding (‘’) variant of the multiline string literal.

Something like this ? (see ‘’ around EOF)

pigeon% cat b.rb
#!/usr/bin/ruby
$a = 12
var = <<‘EOF’
variable #$a
EOF
p var
pigeon%

Or even:
% cat strings.rb
$a = 12
var = ’
variable #$a
Ruby Strings are multi-line by default.

p var

% ruby strings.rb
“\nvariable #$a\nRuby Strings are multi-line by default.\n”

···


Jason Voegele
“We believe that we invent symbols. The truth is that they invent us.”
– Gene Wolfe, The Book of the New Sun

irb(main):001:0> x = <<‘DONE’
irb(main):002:0’ #{raise}
irb(main):003:0’ DONE
" #{raise}\n"

···

Radek Hnilica (Radek@Hnilica.CZ) wrote:

but the last one, multiline, is there only in “” (expanding) variant.
Is there unexpanding (‘’) variant of the multiline string literal.