Mascara Try it Download Buy About Documentation Blog

Array Type Literals

Array type literals are a convenient way to declare the type of an array, using a syntax that looks like an array literal.

Syntax definition [Help]
[ type [ , type ]* [ ... resttype ] ]

A array type can have a fixed number of typed "slots", or be variable size, with all slots having the same type - or a combination. The type after the ellipsis (...) indicates the type of the "rest" of the items.

// two slots, boolean and String
var x : [boolean, String]; 
 
// variable number of slots (zero or more), all int
var y : [...int]; 
 
// first two slots are boolean and String, rest is int
// size is 2 or more.
var z : [boolean, String, ...int];