<br><br><div class="gmail_quote">On Sat, Aug 28, 2010 at 18:19, Jesse Phillips <span dir="ltr"><<a href="mailto:jessekphillips%2BD@gmail.com">jessekphillips+D@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
D uses the last element in the array literal to select the type. I think there was a discussion on why a common type wasn't used, but don't remember the conclusion. It would be nice if it used the item you are assigning to and check they can convert to it.<br>
</blockquote><div><br>No no, it has been changed months ago. It indeed computes the common type, for numeric types at least<br><br>auto a = [1, 2u, 3.45678, 9]; // a is a double[]<br><br>I think it does this with the ?: ternary operator.<br>
<br>As for kickverbot question, I think it's a bug. You should see if it's already in bugzilla, or report it.<br><br>std.traits.CommonType works, though:<br><br>alias CommonType!(A,B) O;<br>writeln(O.stringof); // "Object"<br>
<br>and also the ?: operator:<br><br>writeln(typeof(true ? new A() : new B()).stringof); // "Object"<br><br>Philippe<br><br><br><br></div></div>