From: "Gonzalo Garramuño" Date: 2008-01-03T07:44:09+09:00 Subject: Re: [Spam] Inconsistency in rescuability of "return" Charles Oliver Nutter wrote: > Why can you not rescue return, break, etc when they are within > appropriate structures, but you can rescue them when they are not? > Huh? > Example > > begin > break > rescue > puts 'here' > end > > # output: 'here' > Seems correct. break raises an exception as there's no loop. > while true > begin > break > rescue > puts 'here' > end > end > > # no output, loop terminates > Again, correct. break exits the while true loop. No exception is raised. > Also with return: > > begin > return > rescue > puts 'here' > end > > # output: 'here' > Again, correct. No function is defined. The return statement should raise an exception. > def foo > return > rescue > puts 'here' > end > > foo > > # no output > Again, correct. A function is defined. Return just returns. No exception is raised. > Why do these operations have different behavior in each case? > Are these examples either too simple or did I miss something? -- Gonzalo Garramu�o ggarra@advancedsl.com.ar AMD4400 - ASUS48N-E GeForce7300GT Xubuntu Gutsy