|
|
|
|
|
by msbarnett
3897 days ago
|
|
def some_method
what_is_this
end
> You don't know what what_is_this is. It could be an instance variable, a method (anywhere in the inheritance tower), or an autogenerated method from method_missing. It's impossible to tell without digging through the code.We know it's not an instance variable -- that would be @what_is_this. It would have to be a local variable, but plainly there is no such variable local to this method. So we know it's a method. Let's go hunting (we could do this vis binding.pry, or byebug, or in IRB with an instance of whatever defined some_method): method(:what_is_this) rescue false # if false, this is coming from method_missing
method(:what_is_this).source_location # there's your definition location, if it wasn't coming from method_missing
In general I used to find debugging ruby hard, coming from a background in more static languages. Once I learned the debugging facilities it provides, finding things got a lot easier. |
|