switch case for constants-only?

Ellery Newcomer ellery-newcomer at utulsa.edu
Sat Dec 5 13:51:44 PST 2009


On 12/05/2009 03:39 PM, Nick Sabalausky wrote:
> "Steven Schveighoffer"<schveiguy at yahoo.com>  wrote in message
> news:op.u4hhjisgeav7ka at localhost.localdomain...
>> On Sat, 05 Dec 2009 16:08:00 -0500, Nick Sabalausky<a at a.a>  wrote:
>>
>>> I just noticed in D1 that the values for the cases in a switch must be
>>> known
>>> at compile-time (btw, the docs don't seem somewhat vague on that). Is
>>> this
>>> also true in D2? If so, I don't suppose we could get that changed before
>>> the
>>> book? It's a real PITA for dynamic code.
>>
>> you mean a real PITA to use if instead of switch?
>
> For long "if else(x == y)" chains where the x is always the same? Yes,
> absolutely.
>

More so than remembering to type break after each case block?



More information about the Digitalmars-d mailing list