18

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}"
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
OVERTONE
  • 11,797
  • 20
  • 71
  • 87

1 Answers1

31

You can use __LINE__ variable. See this https://stackoverflow.com/a/2496240/100466 answer also.

Community
  • 1
  • 1
Waseem
  • 8,232
  • 9
  • 43
  • 54