Infer types from property initialization expressions
mainThe @MemberwiseInit macro operates at the syntax level and can infer property types from their initialization expressions. This allows you to omit explicit type annotations for many common Swift types, such as literals, ranges, arrays, dictionaries, and tuples.
@MemberwiseInit
struct Example {
var count = 0 // Inferred as Int
var string = "" // Inferred as String
var boolTrue = true // Inferred as Bool
var mixedDivide = 8.0 / 4 // Inferred as Double
var arrayIntLiteral = [1, 2, 3] // Inferred as [Int]
}