Function taking a variable number of arguments

前端 未结 2 988
忘了有多久
忘了有多久 2021-02-07 02:32

In this document: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2

2条回答
  •  無奈伤痛
    2021-02-07 02:49

    The type of parameter in sumOf are known as 'variadic' parameter. The parameters passed are accepted just as a group of elements and is then converted into array before using it within that function.

    A great example would be this post.

    Passing lists from one function to another in Swift

提交回复
热议问题