A.class_eval(<<-EOF, FILE, LINE)
def method_a
puts “calling method_a…”
end
EOF
A.class_eval <<-EOF
def method_b
puts “calling method_b…”
end
EOF
A.new.method_a
A.new.method_b
Why lot of Rails snippet code use FILE LINE
A.class_eval(<<-EOF, FILE, LINE)
def method_a
puts “calling method_a…”
end
EOF
A.class_eval <<-EOF
def method_b
puts “calling method_b…”
end
EOF
A.new.method_a
A.new.method_b
Why lot of Rails snippet code use FILE LINE
bill gate wrote in post #1064388:
Why lot of Rails snippet code use FILE LINE
FILE and LINE are magic constants. They point to the file/line
they’re in.
In combination with class_eval these constants can be used to produce
exact error messages. If you don’t use them, an error message within the
class_eval will only display the file and line of the “class_eval”.
See
Jan E. wrote in post #1064399:
bill gate wrote in post #1064388:
Why lot of Rails snippet code use FILE LINE
FILE and LINE are magic constants. They point to the file/line
they’re in.In combination with class_eval these constants can be used to produce
exact error messages. If you don’t use them, an error message within the
class_eval will only display the file and line of the “class_eval”.
Greate, Thank you.
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