question for newbie

N

Nericl Lau

a = << END_STR
This is the string
And a second line
END_STR
puts a


What does it mean?
I kept getting this error


q1.rb:1: syntax error, unexpected tLSHFT
a = << END_STR
 
R

Rob Biedenharn

a = << END_STR
This is the string
And a second line
END_STR
puts a


What does it mean?
I kept getting this error


q1.rb:1: syntax error, unexpected tLSHFT
a = << END_STR

It means that you can't have a space or it looks like you're trying to
use the "left shift" operator <<

a = <<END_STR
This is the string
And a second line
END_STR
puts a

Or using the option to allow the ending tag to be indented:

a = <<-END_STR
This is the string
And a second line
END_STR
puts a

Should do what you want.

-Rob

Rob Biedenharn
(e-mail address removed) http://AgileConsultingLLC.com/
(e-mail address removed) http://GaslightSoftware.com/
 
S

Stu

[Note: parts of this message were removed to make it a legal post.]

you need to remove the space between << and END_STR for the heredoc to work

like so

here = <<EOF
I am inside
a here doc
EOF

puts here
 

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,139
Messages
2,570,805
Members
47,352
Latest member
DianeKulik

Latest Threads

Top