<div dir="ltr">Because in your example T = CustomStringConvertible<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 18, 2016 at 10:51 AM, tuuranton--- via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>Why does this compile?</div><div><br></div><div>let t1: Int? = 2</div><div>print(t1 ?? "asdf")</div><div><br></div><div>The type of ?? is this:</div><div><br></div><div>@warn_unused_result</div><div>public func ??<T>(optional: T?, @autoclosure defaultValue: () throws -> T) rethrows -> T</div><div><br></div><div>The type syas that T must be the same type throughout. But above I could successfully use Int? and then String. Why?</div> </div>
<br>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Marius Serban</div>
</div>