Hi all,

this is a rather minor nitpick, I'm just looking for some opinions on this.

Declaring a function that has default parameters currently looks like this:

func foo(bar: String = "baz") {
    print(bar)
}

Now I'm wondering if there would be any problems if it were possible to omit 
the type annotation for default params and let Swift's type inference handle 
that.

func foo(bar = "baz") {
    print(bar)
}

It feels to be equivalent to omitting type annotations with variable 
declarations. Obviously more complex types would still require annotations 
being specified. Off the top of my head I can't think of any negative 
ramifications this might bring, be it in simple function/method declarations or 
protocol extensions and elsewhere.
Any further input on this would be much appreciated :)

Cheers,
Kilian

Attachment: signature.asc
Description: Message signed with OpenPGP

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

Reply via email to