What does class_eval <<-“end_eval”, __FILE__, __LINE__ mean in Ruby?

前端 未结 3 1444
执笔经年
执笔经年 2020-11-30 20:21

I\'m learning how to use class_eval in modules (I\'m somewhat familiar with class_eval) and came across this helpful class in resource_controller. In there they have things

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 20:44

    The << is the start of a heredoc. That line is the start of a multiline string. The string is evaled to create the function. The class_eval function uses the __FILE__ and __LINE__ to add debug information.

提交回复
热议问题