removing default case requirement?
Vladimir Panteleev
thecybershadow.lists at gmail.com
Sun Apr 2 21:02:47 UTC 2023
On Friday, 31 March 2023 at 15:20:41 UTC, Steven Schveighoffer
wrote:
> Imagine if every `if` statement required you to write an `else`
> clause,
(This doesn't seem like that much of a radical idea, considering
that this is the case in functional languages, right?)
> it's usually because I forgot to include `default: break;`.
One small observation, you don't need to add `break;` before `}`.
(The compiler doesn't emit warnings on missing `break`, but on
fall-through, and reaching `}` isn't a fall-through.) Sometimes I
add a comment explaining why the default case does nothing,
instead of raising an exception or something like that.
More information about the Digitalmars-d
mailing list