问题
Crazy thought today.
Is there any way to grab the line number that code has been executed on?
Logger.info "I was run on line #{get_line_number}"
回答1:
You can use __LINE__ variable. See this https://stackoverflow.com/a/2496240/100466 answer also.
来源:https://stackoverflow.com/questions/12175793/getting-current-line-of-code-in-ruby