Long strings

Hi:

I want to create a long string containing line breaks so I wrote
a = <<END
a few lines …
END

but Ruby can never find the closing END anywhere before EOF. Is there
something I’m missing?

Thanks
Matt

Hello Matthew,

Friday, December 27, 2002, 9:44:53 AM, you wrote:

Hi:

I want to create a long string containing line breaks so I wrote
a = <<END
a few lines …
END

but Ruby can never find the closing END anywhere before EOF. Is there
something I’m missing?

sorry, i mean “spaces before second END?”

···


Best regards,
Bulat mailto:bulatz@integ.ru

Hello Matthew,

Friday, December 27, 2002, 9:44:53 AM, you wrote:

Hi:

I want to create a long string containing line breaks so I wrote
a = <<END
a few lines …
END

but Ruby can never find the closing END anywhere before EOF. Is there
something I’m missing?

spaces before second EOF?

···


Best regards,
Bulat mailto:bulatz@integ.ru

In order to indent the terminating word, you need to indicate you want
to indent it using “-”, like so:

   a = <<-END
        a few lines ....
   END

Otherwise, without the “-”, you have to write:

   a = <<-END
        a few lines ....

END

Notice the closing “END” against the left margin.

– Dossy

···

On 2002.12.27, Matthew Huggett mhuggett@zam.att.ne.jp wrote:

Hi:

I want to create a long string containing line breaks so I wrote
a = <<END
a few lines …
END

but Ruby can never find the closing END anywhere before EOF. Is there
something I’m missing?


Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)

Matthew,

From the Pickaxe (Programming Ruby by David Thomas and Andy Hunt), pgs
204-205:
“You can put a minus sign immediately after the << characters, in which case
the terminator can be indented from the left margin.”

But I wouldn’t use the word ‘END’ as a here document terminator-- END is a
standard block to be run after the program has finished executing (Pickaxe pg
202). Apparently Ruby will let you do it (on 1.7.3, at least), but using it
is a Bad Thing, IMHO.

Hope this helps,

~ Bruce

···

On Friday 27 December 2002 01:53 am, Bulat Ziganshin wrote:

Hello Matthew,

Friday, December 27, 2002, 9:44:53 AM, you wrote:

Hi:

I want to create a long string containing line breaks so I wrote
a = <<END
a few lines …
END

but Ruby can never find the closing END anywhere before EOF. Is there
something I’m missing?

spaces before second EOF?


Bruce R. Williams :: [iusris/#ruby-lang] :: http://www.codedbliss.com

‘It does not require a majority to prevail, but rather an irate,
tireless minority keen to set brush fires in people’s minds.’
– Samuel Adams