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
On Fri, Jan 13, 2012 at 7:21 PM, Ondrej Bilka neleai@seznam.cz wrote:
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).
On Fri, Jan 13, 2012 at 11:11:28PM +0900, Anurag Priyam wrote:
On Fri, Jan 13, 2012 at 7:21 PM, Ondrej Bilka neleai@seznam.cz wrote:
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).
Doesn't throw/catch to that already?
No unless you are happy with passing result by global variable.