casting int[] to bool[]
Saaa
empty at needmail.com
Wed Jan 28 18:10:55 PST 2009
:D
Casting an expression to bool means testing for 0 or !=0 for arithmetic
types, and null or !=null for pointers or references.
So a per element bool cast should be safe, right?
That makes my full code like this:
char[][] data;
data=cast(char[][])splitlines(cast(invariant
char[])read(`data\parsed.dat`));
bool[][] dataIn = new bool[][](data.length, 3);
for(int i; i<data.length; i++)
{
int[3] temp = to!(int[])(split(data[i][14..19].idup,`,`)); // 14..19 =
`0,0,1`
foreach(index, t; temp)
{
dataIn[i][index] = cast(bool) t;
}
}
writefln(data[0][14..19]);
writefln(dataIn[0]);
----------It writes correctly:
0,0,1
[false false true]
Yay, thanks
More information about the Digitalmars-d-learn
mailing list