swift function in a variable
var pendingFunction: ((Double, Double) -> Double)
swift function in a variable
var pendingFunction: ((Double, Double) -> Double)
variadic parameters swift
// This function will take multiple `Int` parameters and add them.
// A variadic parameter in a function is denoted by `<TYPE>...`.
// Note that a function can only have 1 variadic parameter unless
// you use Swift 5.4+, with which you can use multiple.
func add(_ addends: Int...) -> Int {
var sum = 0
for num in addends {
sum += num
}
return sum
}
print(add(1, 2, 3, 4)) // 10
print(add(5, 2, 3, 4, 6, 7, 8, 10)) // 45
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us