Promote jump statements syntactically to expressions, similar to how throw
expressions work.
#7754
Replies: 1 comment
-
Duplicate of #867. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is, in my experience a commonly-used pattern:
throw
is a jump statement, and therefore its use as an expression is well-founded: it will never reach the end-point, and therefore whatever value evaluations may come after, are irrelevant.My proposal is that we allow the same of at least
return
.It would maybe be beneficial to allow it of
yield break
as well, due to similar usecase for early termination. The utility of allowing it foryield return
is quiestionable, as is allowing it forbreak
andcontinue
. The less said aboutgoto
the better.The following is another extremely common pattern:
or the more terse version that explicitly matches
arg
into a non-nullval
to appease the type checkerwhich could then be abbreviated to
and even things like
would be possible.
Beta Was this translation helpful? Give feedback.
All reactions