class Crystal::Macros::ArrayLiteral
inherits Crystal::Macros::ASTNode
¶
An array literal.
Methods¶
#[](index : NumberLiteral) : ASTNode
¶
(index : NumberLiteral) : ASTNode
Similar to Array#[]
, but returns NilLiteral
on out of bounds.
#first : ASTNode | NilLiteral
¶
: ASTNode | NilLiteral
Similar to Array#first
, but returns a NilLiteral
if the array is empty.
#last : ASTNode | NilLiteral
¶
: ASTNode | NilLiteral
Similar to Array#last
, but returns a NilLiteral
if the array is empty.
#of : ASTNode | Nop
¶
: ASTNode | Nop
Returns the type specified at the end of the array literal, if any.
This refers to the part after brackets in [] of String
.
#splat(trailing_string : StringLiteral = nil) : MacroId
¶
(trailing_string : StringLiteral = nil) : MacroId
Returns a MacroId
with all of this array's elements joined
by commas.
If trailing_string is given, it will be appended to the result unless this array is empty. This lets you splat an array and optionally write a trailing comma if needed.
#type : Path | Nop
¶
: Path | Nop
Returns the type that receives the items of the array.
This refers to the part before brackets in MyArray{1, 2, 3}