Created
January 24, 2013 21:41
-
-
Save mrjabba/4628080 to your computer and use it in GitHub Desktop.
Ruby kernel#caller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kernel has a great method you can call. "caller". | |
Returns an array of the stack that called you. | |
So if you want to just see your immediate caller, | |
you can do puts "who called me caller=#{caller.first}" | |
and it will print the immediate caller. | |
If your method is being called from multiple clients this seems useful in debugging.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment