bearophile Wrote: > I'm playing with the new D2 a bit, this comes from some real D1 code: > > void main(string[] args) { > int n = args.length; > ubyte m = (n <= 0 ? 0 : (n >= 255 ? 255 : n)); > } > > At compile-time the compiler says: > temp.d(3): Error: cannot implicitly convert expression (n <= 0 ? 0 : n >= 255 > ? 255 : n) of type int to ubyte > > You have to add a silly cast: > > void main(string[] args) { > int n = args.length; > ubyte m = (n <= 0 ? 0 : (n >= 255 ? 255 : cast(ubyte)n)); > } > > In theory if the compiler gets a smarter such cast can be unnecessary. > > Bye, > bearophile
add it to bugzilla.