<br><br><div class="gmail_quote">On Sat, Aug 28, 2010 at 18:19, Jesse Phillips <span dir="ltr">&lt;<a href="mailto:jessekphillips%2BD@gmail.com">jessekphillips+D@gmail.com</a>&gt;</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&#39;t used, but don&#39;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&#39;s a bug. You should see if it&#39;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); // &quot;Object&quot;<br>
<br>and also the ?: operator:<br><br>writeln(typeof(true ? new A() : new B()).stringof); // &quot;Object&quot;<br><br>Philippe<br><br><br><br></div></div>