In Swift,there's no way to get the returned function's argument names?

后端 未结 1 1693
一个人的身影
一个人的身影 2020-12-21 17:54

When a function\'s return value is another function,there\'s no way to get the returned function\'s argument names.Is this a pitfall of swift language?

For example:<

相关标签:
1条回答
  • 2020-12-21 18:27

    You're correct. From the Swift 3 release notes:

    Argument labels have been removed from Swift function types... Unapplied references to functions or initializers no longer carry argument labels.

    Thus, the type of townPlan, i.e. the type returned from calling makeTownGrand, is (Int,Int) -> Int — and carries no external argument label information.

    For a full discussion of the rationale, see https://github.com/apple/swift-evolution/blob/545e7bea606f87a7ff4decf656954b0219e037d3/proposals/0111-remove-arg-label-type-significance.md

    0 讨论(0)
提交回复
热议问题