The assignment statement looks like this:
my_var = false
And breaking on the very next line, the debugger shows 'my_var' with Type=NilClas开发者_运维知识库s and value=nil! How is this possible?
Have you examined my_var
directly without any debugger? The debugger could be getting confused or just displaying confusing results.
It's possible that the target object of your section of code has a "setter method" defined, so it looks like you're assigning to "my_var" but are actually calling the "my_var=
" method. See if your code has any definitions like this:
def my_var=(x)
# ...
end
If so, you'll need to change the name of the local "my_var" variable or the setter method. You could also verify by stepping into the line where you call "my_var = false
".
I found this very helpful True, False and Nil.
精彩评论