[swift-evolution] [Manifesto] Completing Generics

Joe Groff jgroff at apple.com
Thu Mar 10 16:20:37 CST 2016


> On Mar 10, 2016, at 1:59 PM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
> 
> @Joe,
> 
> Yes; but casts can fails in most languages, e.g.:
> 
> func foo() -> Any {
>     return 0;
> }
> 
> let f = foo() as! Float

My point was that `static <Output extends Number> Output foo()` in Java is analogous to `func foo<Output>() -> Output` in Swift. In both languages, the Output type variable is chosen by the caller, so can be all possible types matching those constraints.

-Joe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160310/a276a76a/attachment.html>


More information about the swift-evolution mailing list