# Exception < Object begin puts "starting" todo # not a method puts "ending" # does not get here rescue NameError # predefined exception puts "oops: " + $! # $! has the error message ensure puts "always do this" # always do this end begin puts "input 10 characters or less" s = gets raise "too many" if s.length > 10 # generates exception puts "good entry" # only here if good rescue RuntimeError # type generated puts "you entered too many characters" end catch(:stop) do # labels a block for x in 1..10 y = x*x for z in 1..10 print x," ",y," ", z, "\n" throw :stop if z > y # go to end of end # labeled block end end