[LRUG] To debug the impossible bug
James Cumming
james.cumming at yahoo.co.uk
Wed Aug 3 04:22:44 PDT 2011
Hi
I think Matthew is right - you are trying to use the case statement as an if statement.
"when" produces a positive even if the variable is nil. I think that somehow a nil @question is creeping into your methods.
I tried this in the IRB (which shows the negative positive being produced):
irb(main):001:0> question = nil
=> nil
irb(main):002:0> case
irb(main):003:1* when question
irb(main):004:1> print question
irb(main):005:1> end
=> nil
irb(main):006:0> case
irb(main):007:1* when no_quesiton
irb(main):008:1> print "no question"
irb(main):009:1> end
NameError: undefined local variable or method `no_quesiton' for main:Object
from (irb):7
from C:/Ruby192/bin/irb:12:in `<main>'
Cheers
James Cumming, CFA
+44 7799 554468
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20110803/ccc35387/attachment-0003.html>
More information about the Chat
mailing list