End_eval

Trying to teach myself some metaprogramming and have been sifting
through the rails source. I often see:
module_eval << -end_eval
stuff to add
end_eval

I understand what this does, but I’m curious what part of the language
the -end_eval construct is coming from.

Thanks,
Brad

On 6/26/06, Brad C. [email protected] wrote:

Trying to teach myself some metaprogramming and have been sifting
through the rails source. I often see:
module_eval << -end_eval
stuff to add
end_eval

I understand what this does, but I’m curious what part of the language
the -end_eval construct is coming from.

module_eval <<-EOS
string-of-stuff-to-add
EOS

It’s what’s called a heredoc.

-austin

it’s the same as print << -HERE
HERE
the - means HERE does not have to be the first part of the line and can
be indented

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs