Adding finally to switch

Jesse Phillips jessekphillips at gmail.com
Tue Apr 1 13:32:06 PDT 2008


On Tue, 01 Apr 2008 10:20:04 +0200, Henning Hasemann wrote:

> Jesse Phillips <jessekphillips at gmail.com> wrote:
>> I haven't given it much thought, but I figured I'd let some other
>> people look at it too.
>> 
>> Switch statements are nice, many people hate having to use break; all
>> the time, but I don't and am not interest in the debate. What I think
>> is missing from a switch statement is a finally section. Most of the
>> time I don't have a use for the fall-through feature of switch, but I
>> do have a use for doing one or more things that are the same in every
>> case.
> 
> I don't think I get your point. If you have code that is the same in
> *every* case why cant you do:
> 
> do_this_before_each_case();
> switch(foo) {
>  // ...
> }
> do_this_after_each_case();
> 
> Henning

Well, I was thinking there might be special constraints added to it, like 
Bill's example, where default is left out. But as he should I guess in 
isn't too hard to make your own. To which I say never mind.



More information about the Digitalmars-d mailing list