Variadic parameter in function type


(Jin Wang) #1

Hey guys,

Can anyone tell me how you handle the following scenario after SE-0111 <https://github.com/apple/swift-evolution/blob/master/proposals/0111-remove-arg-label-type-significance.md> gets implemented?

let output: (_ items: Any..., _ separator: String, _ terminator: String) -> Void = print
output("Apple", "Banana", ",", "\n”)
// Error: Missing argument for parameter #2 in call

Thanks,
Jin


(Zhao Xin) #2

It is suggested to put ... part at the end.
Zhaoxin

···

Get Outlook for iOS

On Mon, Aug 29, 2016 at 1:19 PM +0800, "Jin Wang via swift-users" <swift-users@swift.org> wrote:

Hey guys,
Can anyone tell me how you handle the following scenario after SE-0111 gets implemented?
let output: (_ items: Any..., _ separator: String, _ terminator: String) -> Void = printoutput("Apple", "Banana", ",", "
”)// Error: Missing argument for parameter #2 in call
Thanks,Jin


(Jin Wang) #3

Hey Zhao,

Thanks for your reply, but then i can’t use the default value `print` which is the print function Swift provides. Any idea?

Cheers,
Jin

···

On 29 Aug. 2016, at 5:44 pm, zh ao <owenzx@gmail.com> wrote:

It is suggested to put ... part at the end.

Zhaoxin

Get Outlook for iOS <https://aka.ms/o0ukef>

On Mon, Aug 29, 2016 at 1:19 PM +0800, "Jin Wang via swift-users" <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Hey guys,

Can anyone tell me how you handle the following scenario after SE-0111 <https://github.com/apple/swift-evolution/blob/master/proposals/0111-remove-arg-label-type-significance.md> gets implemented?

let output: (_ items: Any..., _ separator: String, _ terminator: String) -> Void = print
output("Apple", "Banana", ",", "\n”)
// Error: Missing argument for parameter #2 in call

Thanks,
Jin


(Zhao Xin) #4

How about this?

func output(_ separator: String, _ terminator: String, _ items: Any...) {

    print(items, separator, terminator)

}

output(",", "\n", "Apple", "Banana")

Zhaoxin

···

On Mon, Aug 29, 2016 at 3:47 PM, Jin Wang <owenwjowenwj@gmail.com> wrote:

Hey Zhao,

Thanks for your reply, but then i can’t use the default value `print`
which is the print function Swift provides. Any idea?

Cheers,
Jin

On 29 Aug. 2016, at 5:44 pm, zh ao <owenzx@gmail.com> wrote:

It is suggested to put ... part at the end.

Zhaoxin

Get Outlook for iOS <https://aka.ms/o0ukef>

On Mon, Aug 29, 2016 at 1:19 PM +0800, "Jin Wang via swift-users" < > swift-users@swift.org> wrote:

Hey guys,

Can anyone tell me how you handle the following scenario after SE-0111
<https://github.com/apple/swift-evolution/blob/master/proposals/0111-remove-arg-label-type-significance.md> gets
implemented?

let output: (_ items: Any..., _ separator: String, _ terminator: String)
-> Void = print
output("Apple", "Banana", ",", "\n”)
// Error: Missing argument for parameter #2 in call

Thanks,
Jin