switch()

Manu turkeyman at gmail.com
Mon Feb 17 18:38:10 PST 2014


On 18 February 2014 09:01, Walter Bright <newshound2 at digitalmars.com> wrote:

> On 2/17/2014 2:43 PM, Ary Borenszweig wrote:
>
>> Now suppose bit_flag can get an additional "new_bit_flag" value. How does
>> "default" helps me notice that I'm supposed to add it to that switch
>> statement?
>>
>
> Because if you account for all the cases, you write:
>
>    default: assert(0);
>
> Now you intentionally tell the user that you intentionally covered all the
> cases.


I think 'final switch' should do that for you, and by typing final, you've
intentionally covered the case. There's no room for mistake then.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140218/04415678/attachment-0001.html>


More information about the Digitalmars-d mailing list