long string assignment

W

w wg

Hi,

In php, I can use the following code :

$str = <<<aa
hello,
how are you?
aa
;

But how can I do this in ruby ?

Thank you.
 
S

Stefano Crocco

Alle luned=EC 11 giugno 2007, w wg ha scritto:
Hi,

In php, I can use the following code :

$str =3D <<<aa
hello,
how are you?
aa
;

But how can I do this in ruby ?

Thank you.

str =3D <<EOS
hello,
how are you?
aa
EOS

Stefano
 
R

Robert Klemme

Hi,

In php, I can use the following code :

$str = <<<aa
hello,
how are you?
aa
;

But how can I do this in ruby ?

str = <<aa
hello,
how are you?
aa

or

# with interpolation, not shown in this example
str = %Q{aa
hello,
how are you?
}

or

# without interpolation
str = %q{aa
hello,
how are you?
}

Kind regards

robert
 
P

Phrogz

or even just

str = %{aa
hello
how are you?
)

msg = "FULL OF INTERPOLATION GOODNESS"
str = %{aa
hello
how ara you?
#{msg}
}

puts str
#=> aa
#=> hello
#=> how ara you?
#=> FULL OF INTERPOLATION GOODNESS
 
R

Rick DeNatale

msg = "FULL OF INTERPOLATION GOODNESS"
str = %{aa
hello
how ara you?
#{msg}
}

puts str
#=> aa
#=> hello
#=> how ara you?
#=> FULL OF INTERPOLATION GOODNESS

Thanks, I corrected my initial typo without too much thought.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,261
Messages
2,571,308
Members
47,967
Latest member
pakasi

Latest Threads

Top