Issue #5893 has been reported by Ondrej Bilka.

----------------------------------------
Feature #5893: named  return,next...
https://bugs.ruby-lang.org/issues/5893

Author: Ondrej Bilka
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 2.0.0


Hello. As returning from various blocks is recurring theme at list I propose following.

You can assign label to each block. You can exit given block by referring to its label.
Syntax can be ::label to avoid ambiguity(But prettier syntax would be desirable).

return,next,break,redo would work as they do now.


Here is example

while::loop true
  10.times{|i|::outer
    10.times{|j|::inter
      next::outer    if i>6
      return::inner 42 if j>4
      puts i,j
    }
  }::outer #For readability we could optionaly add label at end of block.
  break::loop
end


-- 
http://bugs.ruby-lang.org/