class

Crystal::Macros::HashLiteral

Inherits Crystal::Macros::ASTNode

A hash literal.

Instance methods

[](key : ASTNode) : ASTNode

Similar to Hash#[]?

Source
[]=(key : ASTNode, value : ASTNode) : ASTNode

Similar to Hash#[]=

Source
clear

Similar to Hash#clear

Source
double_splat(trailing_string : StringLiteral = nil) : MacroId

Returns a MacroId with all of this hash elements joined by commas.

If trailing_string is given, it will be appended to the result unless this hash is empty. This lets you splat a hash and optionally write a trailing comma if needed.

Source
each

Similar to Hash#each

Source
empty?

Similar to Hash#empty?

Source
has_key?(key : ASTNode) : BoolLiteral

Similar to Hash#has_hey?

Source
keys

Similar to Hash#keys

Source
map

Similar to Hash#map

Source
of_key

Returns the type specified at the end of the Hash literal, if any.

This refers to the key type after brackets in {} of String => Int32.

Source
of_value

Returns the type specified at the end of the Hash literal, if any.

This refers to the value type after brackets in {} of String => Int32.

Source
reject

Similar to Hash#reject

Source
reject(*keys : ASTNode) : HashLiteral

Returns a new HashLiteral without the provided keys.

Source
select

Similar to Hash#select

Source
select(*keys : ASTNode) : HashLiteral

Returns a new HashLiteral with only the provided keys.

Source
size

Similar to Hash#size

Source
to_a

Similar to Hash#to_a

Source
type

Returns the type that receives the items of the array.

This refers to the part before brackets in MyHash{'a' => 1, 'b' => 2}

Source
values

Similar to Hash#values

Source