Skip to content

class Crystal::Macros::ArrayLiteral
inherits Crystal::Macros::ASTNode

An array literal.

Methods

#+(other : ArrayLiteral) : ArrayLiteral

Similar to Array#+.

View source

#<<(value : ASTNode) : ArrayLiteral

Similar to Array#<<.

View source

#[](index : NumberLiteral) : ASTNode

Similar to Array#[], but returns NilLiteral on out of bounds.

View source

#[]=(index : NumberLiteral, value : ASTNode) : ASTNode

Similar to Array#[]=.

View source

#all?(&) : BoolLiteral

Similar to Enumerable#all?

View source

#any?(&) : BoolLiteral

Similar to Enumerable#any?

View source

#clear : ArrayLiteral

Similar to Array#clear

View source

#each(&) : Nil

Similar to Array#each

View source

#each_with_index(&) : Nil

View source

#empty? : BoolLiteral

Similar to Array#empty?

View source

#find(&) : ASTNode | NilLiteral

Similar to Enumerable#find

View source

#first : ASTNode | NilLiteral

Similar to Array#first, but returns a NilLiteral if the array is empty.

View source

#includes?(node : ASTNode) : BoolLiteral

View source

#join(separator) : StringLiteral

Similar to Enumerable#join

View source

#last : ASTNode | NilLiteral

Similar to Array#last, but returns a NilLiteral if the array is empty.

View source

#map(&) : ArrayLiteral

Similar to Enumerable#map

View source

#map_with_index(&) : ArrayLiteral

View source

#of : 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.

View source

#push(value : ASTNode) : ArrayLiteral

Similar to Array#push.

View source

#reduce(memo : ASTNode, &) : ASTNode

Similar to Enumerable#reduce

View source

#reduce(&) : ASTNode

Similar to Enumerable#reduce

View source

#reject(&) : ArrayLiteral

Similar to Enumerable#reject

View source

#select(&) : ArrayLiteral

Similar to Enumerable#select

View source

#shuffle : ArrayLiteral

Similar to Array#shuffle

View source

#size : NumberLiteral

Similar to Array#size

View source

#sort : ArrayLiteral

Similar to Array#sort

View source

#sort_by(&) : ArrayLiteral

Similar to Array#sort_by

View source

#splat(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.

View source

#type : Path | Nop

Returns the type that receives the items of the array.

This refers to the part before brackets in MyArray{1, 2, 3}

View source

#uniq : ArrayLiteral

Similar to Array#uniq

View source

#unshift(value : ASTNode) : ArrayLiteral

Similar to Array#unshift.

View source