Yield break with return value #5033
-
When breaking an iterator, two statements inside a code block are required, e.g.
With a combined return/break statement for example called "yieldlast" (or something less awkward), these four lines could be reduced to one -
Or to avoid new reserved words, yield break could have an optional parameter:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Why would it be worthwhile to add special syntax for this particular pattern? It isn't the goal of the language to make every program as short as possible. |
Beta Was this translation helpful? Give feedback.
-
Actually, I think that is a pretty good suggestion. Something like |
Beta Was this translation helpful? Give feedback.
Why would it be worthwhile to add special syntax for this particular pattern? It isn't the goal of the language to make every program as short as possible.