Função de conversão implícita recebendo tupla
Acabei de descobrir que há um elenco implícito:
De função tomando n parâmetros(A, B, ...) -> R
Para executar uma n-tupla((A, B, ...)) -> R
Exemplo n ° 1
func withTuple(_ a: (Int, Int)) { }
func withoutTuple(_ a: Int, _ b: Int) { }
func call(tupleFunction: ((Int, Int)) -> ()) {
tupleFunction((1, 2))
}
call(tupleFunction: withTuple)
call(tupleFunction: withoutTuple) // Magic here
(Código Swift 4.2 válido)
Exemplo n ° 2
[(1, 2), (3, 3)].map(*) // Magic here
Esse comportamento está documentado em algum lugar?