Can a Swift func/closure signature specify that default parameter values are provided?
A highly simplified version of what I'm trying to do is this:
struct L {
typealias W = ((String, String, String) -> Void)
static func w(_ w:String, _ t:String = "t", _ f:String = "f") {
let line = w + t + f
print(line)
}
static let ws:[W] = [L.w, L.w]
}
L.ws[0]("sue", "seven", "red")
L.ws[0]("bill")
The error I get at the "bill" call is: error: missing argument for parameter #2 in call
I tried changing the typealias line to:
typealias W = ((String, String = "t", String = "f") -> Void)
But that gives me an error at the typealias line: error: default argument not permitted in a tuple type
This does not help either:
typealias W = ((String, String?, String?) -> Void)
whas defaulted arguments, its type is still(String, String, String) -> Void- Alexander