3 ms·
It strikes a balance, by allowing _literals_ to be implicitly converted as needed. E.g. `someDouble * 1` is valid, without needing to write `1.0` or `1f`. Thi
by amomchilov 2y ago
It strikes a balance, by allowing _literals_ to be implicitly converted as needed.
E.g. `someDouble * 1` is valid, without needing to write `1.0` or `1f`.
This is because `Double` conforms to the `ExpressibleByIntegerLiteral` protocol. There's other similar protocols for other literal types, which e.g. you could write:
let s: Set = [1, 2, 3]
Where it would have defaulted to being an Array without the annotation.