Skip to content

Neat 0.4.2: Breaking else again

Compare
Choose a tag to compare
@FeepingCreature FeepingCreature released this 12 Oct 11:34
· 179 commits to master since this release

Okay, I'm restructuring breakelse again. Now, the ternary operator a if b else c fully supports breakelse and has a shortened form: a else b (the "short ternary operator"). In that case, the if-test is always true, so the else case can only be reached by breakelse or ?.

In exchange, .else() is removed entirely: it was redundant with ?, and the code ended up with two different operations in the same expression that did the same thing. a.else(b) should be replaced with (a? else b), or a.(that? else b) if you really need the property form.

State of play:

auto var = obj?.field? else return false;

if (auto var = obj?.field?) { }