It seems pure ain't so pure after all

Tommi tommitissari at hotmail.com
Sun Sep 30 22:40:37 PDT 2012


import std.stdio;

int pow2(int val) pure
{
     if (__ctfe)
         return 6;
     else
         return val * val;
}

void main()
{
            assert(pow2(3) == 9);
     static assert(pow2(3) == 6);

     writeln("9 = 6 ... I knew it! '6' was faking it all along");
     readln();
}


More information about the Digitalmars-d mailing list