P
Patrick Li
Hi,
I'm having trouble locating this bug that I'm having. I think it's
because I don't completely understand Ruby's throw/catch mechanism.
I'm trying to write a simple example that demonstrates the same problem,
but I can't track down the bug.
Here's my code: Is there any subtleties that may cause throw/catch to
not behave as expected?
def idle(engine,key)
catchexit) do <-- Catch :exit
while engine.nextFrame(key)
engine.drawFrame do
drawInContext(@img, 0, 0, 1)
end
@enterEvent.listen do
@state = methodactive)
puts "player entered"
throw :exit <-- Throw :exit
end
end
end
end
Gives me: "in `throw': uncaught throw `exit' (NameError)"
And what's really strange is, the problem goes away after putting in a
print statement.
def idle(engine,key)
catchexit) do <-- Catch :exit
while engine.nextFrame(key)
engine.drawFrame do
drawInContext(@img, 0, 0, 1)
end
@enterEvent.listen do
@state = methodactive)
puts "player entered"
throw :exit <-- Throw :exit
end
end
end
puts "end" <-- This line causes the problem to go away.
end
Thanks a lot for your help. Any place to start looking would be really
helpful. I'm fresh out of ideas.
-Patrick
I'm using Ruby 1.8.6 on Windows.
I'm having trouble locating this bug that I'm having. I think it's
because I don't completely understand Ruby's throw/catch mechanism.
I'm trying to write a simple example that demonstrates the same problem,
but I can't track down the bug.
Here's my code: Is there any subtleties that may cause throw/catch to
not behave as expected?
def idle(engine,key)
catchexit) do <-- Catch :exit
while engine.nextFrame(key)
engine.drawFrame do
drawInContext(@img, 0, 0, 1)
end
@enterEvent.listen do
@state = methodactive)
puts "player entered"
throw :exit <-- Throw :exit
end
end
end
end
Gives me: "in `throw': uncaught throw `exit' (NameError)"
And what's really strange is, the problem goes away after putting in a
print statement.
def idle(engine,key)
catchexit) do <-- Catch :exit
while engine.nextFrame(key)
engine.drawFrame do
drawInContext(@img, 0, 0, 1)
end
@enterEvent.listen do
@state = methodactive)
puts "player entered"
throw :exit <-- Throw :exit
end
end
end
puts "end" <-- This line causes the problem to go away.
end
Thanks a lot for your help. Any place to start looking would be really
helpful. I'm fresh out of ideas.
-Patrick
I'm using Ruby 1.8.6 on Windows.