From: John Pritchard-williams Date: 2008-08-29T06:15:27+09:00 Subject: Re: Subtle bug with catch/throw. Am I missing something? Patrick Li wrote: > Thanks for your responses. > > I think I understand now. I was just using the catch as a lazy way to > break out of the loop. I can just use a loop flag instead then. > > I still don't know why the "puts" statement avoids the error. The "do" > after the "while" doesn't help either. Patrick, Again total guesswork , but based on the other posts from people who actually know what they are talking about... - sounds like the symbol ':exit' is possibly out-of-scope by the time the 'throw' is executed. So (purely out of interest, as you are solving this another way...) Could you try replacing :exit with an instance or class-based variable like: def initialize @exit=:exit end And then refer to it in both your catch and throw ? (or at least your catch..) Again, based on what's been posted here - sounds like timing plays a role here: maybe the 'puts' delays execution just-enough to keep the thread-of-execution within the method for the 'throw' to find the referring catch...? This is quite an interesting problem...I'm learning quite a bit about ruby just from watching the other posts ! :) Cheers John -- Posted via http://www.ruby-forum.com/.