How to assign multiple values to multiple variables in one line with Swift

1 Answer

0 votes
import Foundation

let (a, b, c, d, e) = (1, "Swift", 3.14, -2.0, -5)

print("\(a) \(b) \(c) \(d) \(e)")

print(type(of: a), type(of: b), type(of: c), type(of: d), type(of: e))



/*
run:

1 Swift 3.14 -2.0 -5
Int String Double Double Int

*/

 



answered Jul 14, 2025 by avibootz
...