[swift-users] Default value for throwing closure argument of a rethrowing function

bhargav gurlanka bhargav.grlnk at gmail.com
Mon May 16 04:35:39 CDT 2016

Hi all,

Could someone please tell me why the following fails?

func foo(f: () throws -> () = {}) rethrows {
    try f()

// Fine
foo({ })

// This fails with error:
//    call is to 'rethrows' function,
//    but a defaulted argument function can throw

Why should I have to write "try foo()", shouldn't it take the default value
(non throwing closure)?

Bhargav Gurlanka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160516/af1f444d/attachment.html>

More information about the swift-users mailing list