Because in your example T = CustomStringConvertible

On Mon, Apr 18, 2016 at 10:51 AM, tuuranton--- via swift-users <
swift-users@swift.org> wrote:

> Why does this compile?
>
> let t1: Int? = 2
> print(t1 ?? "asdf")
>
> The type of ?? is this:
>
> @warn_unused_result
> public func ??<T>(optional: T?, @autoclosure defaultValue: () throws -> T)
> rethrows -> T
>
> The type syas that T must be the same type throughout. But above I could
> successfully use Int? and then String. Why?
>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>


-- 
Marius Serban
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to