New optional array access operator may fail on compilation with nil arrays
Closed this issue · 0 comments
yoavj-arpeely commented
If the compiler knows a variable is nil, the (very cool!) ?.[] operator fails.
Examples:
The following expression fails on compilation:
let arr = nil;
arr?.[3]
The error is:
type <nil>[int] is undefined (4:6)
This one, however, succeed:
let x = 3;
let arr = x < 4 ? nil : [1];
arr?.[0]