[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

long string assignment

w wg

6/11/2007 2:27:00 PM

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.
--
--
WenGe Wang

7 Answers

Stefano Crocco

6/11/2007 2:29:00 PM

0

Alle lunedì 11 giugno 2007, w wg ha scritto:
> 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.

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

Stefano

w wg

6/11/2007 2:36:00 PM

0

Thank you very much. it works.

2007/6/11, Stefano Crocco <stefano.crocco@alice.it>:
> Alle lunedì 11 giugno 2007, w wg ha scritto:
> > 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.
>
> str = <<EOS
> hello,
> how are you?
> aa
> EOS
>
> Stefano
>
>


--
--
WenGe Wang

Robert Klemme

6/11/2007 2:40:00 PM

0

On 11.06.2007 16:26, w wg wrote:
> 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

Rick DeNatale

6/11/2007 6:35:00 PM

0

On 6/11/07, Robert Klemme <shortcutter@googlemail.com> wrote:

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

or even just

str = %{aa
hello
how are you?
)

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

IPMS/USA Region 12 Coordinator
http://ipmsr12.denh...

Visit the Project Mercury Wiki Site
http://www.mercuryspace...

Rick DeNatale

6/11/2007 6:36:00 PM

0

On 6/11/07, Rick DeNatale <rick.denatale@gmail.com> wrote:
> On 6/11/07, Robert Klemme <shortcutter@googlemail.com> wrote:
>
> >
> > or
> >
> > # without interpolation
> > str = %q{aa
> > hello,
> > how are you?
> > }
>
> or even just
>
> str = %{aa
> hello
> how are you?
> )
>

Oops, I meant either

str = $(aa
hello
how are you?
)

or

str = ${aa
hello
how are you?
}


--
Rick

Gavin Kistner

6/11/2007 6:38:00 PM

0

On Jun 11, 12:34 pm, "Rick DeNatale" <rick.denat...@gmail.com> wrote:
> On 6/11/07, Robert Klemme <shortcut...@googlemail.com> wrote:
> > # without interpolation
> > str = %q{aa
> > hello,
> > how are you?
> > }
>
> 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

Rick DeNatale

6/11/2007 8:22:00 PM

0

On 6/11/07, Phrogz <gavin@refinery.com> wrote:
> On Jun 11, 12:34 pm, "Rick DeNatale" <rick.denat...@gmail.com> wrote:
> > On 6/11/07, Robert Klemme <shortcut...@googlemail.com> wrote:
> > > # without interpolation
> > > str = %q{aa
> > > hello,
> > > how are you?
> > > }
> >
> > 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

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

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...