[ create a new paste ] login | about

Link: http://codepad.org/bvk63OPw    [ raw code | output | fork ]

Trass3r - D, pasted on Jan 3:
import std.stdio;

static const f = [1.34, 6.45, 12.3];
static g = [1.34, 6.45, 12.3];
enum h = [1.34, 6.45, 12.3];
const i = [1.34, 6.45, 12.3];

auto f2 = cast(int[]) f;
// auto g2 = cast(int[]) g; // gives non-constant expression
auto h2 = cast(int[]) h;
auto i2 = cast(int[]) i;

void main()
{
   writefln("%s", cast(int[]) [1.34, 6.45, 12.3]);
	
   writefln("%s", cast(int[]) f);
   writefln("%s", cast(int[]) g);
   writefln("%s", cast(int[]) h);
   writefln("%s", cast(int[]) i);

   writefln("%s", f2);
   writefln("%s", h2);
   writefln("%s", i2);
}

/* Output in D2:

1 6 12
1 6 12
-687194767 1073049763 -858993459 1075432652 -1717986918 1076402585
1 6 12
1 6 12
1 6 12
1 6 12
1 6 12
*/


Output:
1
2
Line 5: enum declaration is invalid
Line 5: Declaration expected, not '='


Create a new paste based on this one


Comments: