Re: Proper switching and casing.
Re: Proper switching and casing.
- Subject: Re: Proper switching and casing.
- From: Steve Mills <email@hidden>
- Date: Thu, 09 Apr 2015 16:33:36 -0500
On Apr 9, 2015, at 16:05:57, Alex Zavatone <email@hidden> wrote:
>
> Is there any reasonable case where you'd want a case condition to not have a break statement after it?
Sure, and it happens a lot:
switch(justification) {
case kLeft:
case kCenter:
case kRight:
DoRegularReflow();
break;
case kFullJustifyNormal:
case kFullJustifyEvenLastLine:
DoJustifiedReflow();
break;
}
If I ever have a case that has code AND falls through, I make sure I mark it as such in lieu of a break:
case 0:
Something();
break;
case 1:
printf("Hey, it's doing that thing you wanted to know about.\n");
// Fall through!
case 2: {
NSString* s = [self getString];
Blah(s);
break;
}
--
Steve Mills
Drummer, Mac geek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden