On 07/24/2016 07:15 PM, Gorge Jingale wrote:
Is there a static ternary if?

(A == B) ? C : D;

for compile type that works like static if.

The way to force an expression at compile time is to use it for something that's needed at compile time. For example, you can initialize a manifest constant (enum) with that expression:

void main() {
    enum i = (__MODULE__.length % 2) ? 42 : 43;
    pragma(msg, i);
}

Instead of enum, you can use 'static const' as well.

Ali

Reply via email to