About switch case statements...
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Nov 16 10:37:52 PST 2009
KennyTM~ wrote:
> On Nov 17, 09 01:40, Andrei Alexandrescu wrote:
>> Bill Baxter wrote:
>>> On Mon, Nov 16, 2009 at 8:24 AM, Andrei Alexandrescu
>>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>> Walter Bright wrote:
>>>>> Andrei Alexandrescu wrote:
>>>>>> I was hoping the lesson learned would be to fix switch as was
>>>>>> suggested.
>>>>> I checked, because it wasn't written in the way I usually write
>>>>> things,
>>>>> and sure enough it wasn't code I wrote :-)
>>>>>
>>>>> From the changelog for D 0.129: "Incorporated Ben Hinkle's new
>>>>> std.format
>>>>> which can print general arrays."
>>>>>
>>>>> http://www.digitalmars.com/d/1.0/changelog1.html#new0129
>>>> So people are liable to make the mistake.
>>>>
>>>> Andrei
>>>>
>>>
>>> What about when you want to fall through to a multiple label? Or a
>>> range label?
>>>
>>> case 0:
>>> // do stuff
>>> goto case ??;
>>> case 1: .. case 9:
>>> // do more stuff
>>> goto case ??;
>>> case 10,20,30:
>>> // still more stuff
>>>
>>> The obvious answer would seem to be just "pick any one".
>>> I just bring it up because I haven't seen that ... uh case ...
>>> mentioned by anyone.
>>>
>>> --bb
>>
>> You must pick the median :o).
>>
>> Andrei
>
> No way we'll need to write "goto case 3.5;" :p
(Just for precision's sake)
median != average
Andrei
More information about the Digitalmars-d
mailing list