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?

Reply via email to