Project

General

Profile

Actions

Feature #5893

closed

named return,next...

Added by neleai (Ondrej Bilka) almost 13 years ago. Updated over 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
[ruby-core:42113]

Description

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0