Is this reasonable?
Steve Teale
steve.teale at britseyeview.com
Thu Dec 5 09:15:37 PST 2013
Here I feel like a beginner, but it seems very unfriendly:
import std.stdio;
struct ABC
{
double a;
int b;
bool c;
}
ABC[20] aabc;
void foo(int n)
{
writefln("n: %d, aabc.length: %d", n, aabc.length);
if (n < aabc.length)
writeln("A");
else
writeln("B");
}
void main(string[] args)
{
int n = -1;
foo(n);
}
This comes back with "B".
If I change the test to (n < cast(int) aabc.length), then all is
well.
Is this unavoidable, or could the compiler safely make the
conversion implicitly?
More information about the Digitalmars-d-learn
mailing list