codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
import std.stdio, std.string; struct Foo { int something; char[] toString() { return format("%s", something); } } Foo[] test = cast(Foo[])([1, 2, 3, 4]); static x = [1, 2, 3, 4]; static x2 = [1.34, 6.45, 12.3]; void main() { writefln("%s", test); writefln("%s", cast(Foo[])(x)); //and this made many people believe that casting arrays does the right thing: writefln("%s", cast(int[])([1.34, 6.45, 12.3])); //but it doesn't work writefln("%s", cast(int[])x2); }
Private
[
?
]
Run code
Submit