From: 7stud -- Date: 2007-09-22T11:13:00+09:00 Subject: Re: Break loop by trapping INT Morton Goldberg wrote: > When the trap is triggered, the trap's proc object receives a 'call' > message. This happens in the scope of top level, not in the scope of > the while block. To get the result you want, you need to invoke a non- > local jump mechanism. This can be done with catch and throw. > > trap('INT') { puts "done"; throw :quit } > > count = 0 > catch :quit do > while count < 10; > puts count += 1 > sleep 1 > end > end Yikes! Isn't that using catch/throw as a plain vanilla goto? -- Posted via http://www.ruby-forum.com/.