From: "Jesús Gabriel y Galán" Date: 2010-12-07T19:57:35+09:00 Subject: Re: why catch block directly exeute On Tue, Dec 7, 2010 at 11:35 AM, Durga B. wrote: > Thank you very much Jesús Gabriel y Galán but some confusion please > explain with different catch and throw,not include same both are same > block take as a different ,please. I'm not sure I understand your question. The way it works is that when you throw, Ruby looks up through the stack for a catch with the same symbol. If it finds it, the block passed to catch is terminated immediately, and the block returns the value passed to throw. This is useful to exit from a deeply nested structure, for example (based on http://phrogz.net/programmingruby/tut_exceptions.html) : def processValue value throw :quit if value =~ /quit!/i value.downcase end def promptAndGet(prompt) print prompt value = gets.chomp processValue value end catch :quit do name = promptAndGet "Name: " age = promptAndGet "Age: " sex = promptAndGet "Sex: " #do_something_with name, age, sex end You can nest catch blocks: catch(:first_level) do puts "at first level" catch(:second_level) do puts "At second level" if (rand(2) == 0) throw :second_level else throw :first_level end puts "still in second level" end puts "still in first level" end Jesus.