class Crystal::Macros::ArrayLiteral

Overview

An array literal.

Defined in:

compiler/crystal/macros.cr

Instance Method Summary

Instance methods inherited from class Crystal::Macros::ASTNode

!=(other : ASTNode) : BoolLiteral !=, ==(other : ASTNode) : BoolLiteral ==, class_name : StringLiteral class_name, column_number : StringLiteral | NilLiteral column_number, doc : StringLiteral doc, doc_comment : MacroId doc_comment, end_column_number : StringLiteral | NilLiteral end_column_number, end_line_number : StringLiteral | NilLiteral end_line_number, filename : StringLiteral | NilLiteral filename, id : MacroId id, is_a?(type : TypeNode) : BoolLiteral is_a?, line_number : StringLiteral | NilLiteral line_number, nil? : BoolLiteral nil?, raise(message) : NoReturn raise, stringify : StringLiteral stringify, symbolize : SymbolLiteral symbolize, warning(message : StringLiteral) : NilLiteral warning

Instance Method Detail

def *(other : NumberLiteral) : ArrayLiteral #

Similar toArray#*


def +(other : ArrayLiteral) : ArrayLiteral #

Similar toArray#+.


def -(other : ArrayLiteral) : ArrayLiteral #

Similar toArray#-.


def <<(value : ASTNode) : ArrayLiteral #

Similar toArray#<<.


Similar toArray#[]?(Int, Int).


def [](index : NumberLiteral) : ASTNode #

Similar toArray#[]?(Int).


Similar toArray#[]?(Range).


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

Similar toArray#[]=.


def all?(&) : BoolLiteral #

Similar toEnumerable#all?


def any?(&) : BoolLiteral #

Similar toEnumerable#any?


def clear : ArrayLiteral #

Similar toArray#clear


def each(&) : NilLiteral #

Similar toArray#each


def each_with_index(&) : NilLiteral #

def empty? : BoolLiteral #

Similar toArray#empty?


def find(&) : ASTNode | NilLiteral #

Similar toEnumerable#find


def first : ASTNode | NilLiteral #

Similar toArray#first, but returns aNilLiteral if the array is empty.


def includes?(node : ASTNode) : BoolLiteral #

def join(separator) : StringLiteral #

Similar toEnumerable#join


def last : ASTNode | NilLiteral #

Similar toArray#last, but returns aNilLiteral if the array is empty.


def map(&) : ArrayLiteral #

Similar toEnumerable#map


def map_with_index(&) : ArrayLiteral #

def 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.


def push(value : ASTNode) : ArrayLiteral #

Similar toArray#push.


def reduce(memo : ASTNode, &) : ASTNode #

Similar toEnumerable#reduce


def reduce(&) : ASTNode #

Similar toEnumerable#reduce


def reject(&) : ArrayLiteral #

Similar toEnumerable#reject


def select(&) : ArrayLiteral #

Similar toEnumerable#select


def shuffle : ArrayLiteral #

Similar toArray#shuffle


def size : NumberLiteral #

Similar toArray#size


def sort : ArrayLiteral #

Similar toArray#sort


def sort_by(&) : ArrayLiteral #

Similar toArray#sort_by


def splat(trailing_string : StringLiteral = nil) : MacroId #

Returns aMacroId with all of this array's elements joined by commas.

Iftrailing_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.


def type : Path | Nop #

Returns the type that receives the items of the array.

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


def uniq : ArrayLiteral #

Similar toArray#uniq


def unshift(value : ASTNode) : ArrayLiteral #

Similar toArray#unshift.