switch()
Steven Schveighoffer
schveiguy at yahoo.com
Sun Feb 16 12:57:12 PST 2014
On Sun, 16 Feb 2014 11:37:48 -0500, Mike Parker <aldacron at gmail.com> wrote:
> On 2/17/2014 12:42 AM, Manu wrote:
>> So D offers great improvements to switch(), but there are a few small
>> things I wonder about.
>>
>> 1.
>> case fall-through is not supported; explicit 'goto case n;' is required.
>
> I only get the error when falling through to default, in which case it
> says:
>
> Error: switch case fallthrough - use 'goto default;' if intended
>
> Fall-through compiles and runs otherwise. This is something I'm doing
> right now:
>
> switch( event.type ) {
> // No error on falling through here <<<---------------------.
> case SDL_KEYDOWN:
> case SDL_KEYUP:
This is allowed, because there is no code between the case statements.
It's the one case where fallthrough is allowed. If you put a statement in
between the two, it would complain.
-Steve
More information about the Digitalmars-d
mailing list