|
|||
|
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 -- Posted via http://www.ruby-forum.com/. |
|
|
||||
|
||||
|
|
|
|||
|
On Feb 18, 2011, at 4:25 PM, Nericl Lau wrote:
> 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 Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/ |
|
|||
|
[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 On Fri, Feb 18, 2011 at 3:25 PM, Nericl Lau <nericlau@gmail.com> wrote: > 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 > > -- > Posted via http://www.ruby-forum.com/. > > |
|
|||
|
On Fri, Feb 18, 2011 at 4:25 PM, Nericl Lau <nericlau@gmail.com> wrote:
> 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 > That's called a heredoc string. See http://www.ruby-doc.org/docs/ruby-do....html#here_doc you have an extra space between << and END_STR try this: a = <<END_STR hello world END_STR puts a |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|