[Pitch] InlineArray type sugar

“Count should be on the left” - very good point.

How about 5[Int] or [5]Int?
Would that be ambiguous?


Edit: the latter variant would combine more easy in multidimensional case:

5[6[7[Int]]] vs [5][6][7]Int

vs proposed: [5 x [6 x [7 x Int]]]


Edit2: Some examples:

let x: [5]Int = [1, 2, 3, 4, 5]
let x: [_]Int = [1, 2, 3, 4, 5] // count inferred
let x: [5]_ = [1, 2, 3, 4, 5] // type inferred
let x: [_]_ = [1, 2, 3, 4, 5] // both type and count inferred
let x: []Int // potentially a new name for [Int]

Edit3: Applying this notation to dictionary types:

var x: [String: [Int: [Bool: String]]] = ...
var y: [String][Int][Bool]String = ...
y["key"]![42]![true] = "value"
1 Like