Why does the following statement give syntax error “undefined method
`STDOUT’”?
STDOUT <<-END
line 1
line 2
END
After all, the following works:
s=<<-END
line 1
line 2
END
STDOUT << s
Why does the following statement give syntax error “undefined method
`STDOUT’”?
STDOUT <<-END
line 1
line 2
END
After all, the following works:
s=<<-END
line 1
line 2
END
STDOUT << s
Ronald F. wrote:
Why does the following statement give syntax error “undefined method
`STDOUT’”?STDOUT <<-END
line 1
line 2
END
Because that’s equivalent to STDOUT “bla”, not STDOUT << “bla”.
The << in your code is part of the heredoc syntax. You want
STDOUT << <<-END
line 1
line 2
END
HTH,
Sebastian
Ronald F. wrote:
Why does the following statement give syntax error “undefined method
`STDOUT’”?STDOUT <<-END
line 1
line 2
END
this means:
tmp_str=“line 1\nline 2\n”;
STDOUT tmp_str;
After all, the following works:
s=<<-END
line 1
line 2
END
STDOUT << s
and this means:
tmp_str=“line 1\nline 2\n”;
STDOUT<<tmp_str;
STDOUT is a var(the std out)
“<<” is a method of STDOUT
------yours Killy Draw
The << in your code is part of the heredoc syntax. You want
STDOUT << <<-END
line 1
line 2
END
Of course, that’s it!!! I must have been blind! Thanks a lot.
Ronald
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs