Project

General

Profile

Feature #7882

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

=begin 
 The keywords `rescue`, `else` (({rescue})), (({else})) and `ensure` (({ensure})) can be used when defining methods like so: 

 ```ruby 
 

   def foo 
     # 
   rescue 
     # 
 rescue 
   else 
     # 
 else 
   ensure 
     # 
 ensure 
   # 
 end 
 ``` 

 However when using a block delimited by do..end, you must use `begin`..`end` (({begin}))..(({end})) as well: 

 ```ruby 
 

   foo do 
   
     begin 
     
       # ... 
   
     rescue 
     
       # ... 
     
       # ... 
     end 
   end 
 end 
 ``` 

 It would be nice to be able to drop the extra `begin`..`end` (({begin}))..(({end})) and use `rescue`, (({rescue})), etc. clauses directly: 

 ```ruby 
 

   foo do 
   
     # ... 
 
   rescue 
   
     # ... 
   
     # ... 
 
   end 
 ``` 

 I cannot think of any ambiguities this syntax would cause, but please correct me if I am wrong. 
 =end

Back