Variadic functions can be called with any number of trailing arguments. Same like print(...) for Swift. Can be used with define type e.g. "String, Int.." or Any protocol.
/// variadic func variadic (any: Any...) { if any.isEmpty { return } for val in any { print(val) } } variadic(any: "hello", "world", 2017, 2.0)
Post a Comment