Project

General

Profile

Actions

Feature #5893

closed

named return,next...

Added by neleai (Ondrej Bilka) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Priority:
Normal
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