class Immutable::Map::Transient(K, V)

Defined in:

immutable/map.cr

Constructors

Instance Method Summary

Instance methods inherited from class Immutable::Map(K, V)

==(other : Map) ==, [](key : K) [], []?(key : K) []?, delete(key : K) delete, each(&)
each
each
, each_key(&block : K -> )
each_key
each_key
, each_value(&block : V -> )
each_value
each_value
, fetch(key : K, default)
fetch(key : K)
fetch(key : K, &block : K -> _)
fetch
, hash hash, inspect(io : IO) inspect, keys keys, merge(hash : Hash(K, V))
merge(map : Map(K, V))
merge(hash : Hash(L, W)) forall L, W
merge(map : Map(L, W)) forall L, W
merge
, set(key : K, value : V) set, size size, to_json(json : JSON::Builder) to_json, to_s(io : IO) to_s, transient(&) transient, values values

Constructor methods inherited from class Immutable::Map(K, V)

new(hash : Hash(K, V) = {} of K => V)
new(hash : Hash(K, V) = {} of K => V, &block : K -> V)
new(e : Enumerable(Tuple(_, _)))
new

Class methods inherited from class Immutable::Map(K, V)

[](hash : Hash(K, V) = {} of K => V) []

Constructor Detail

def self.new(hash : Hash(K, V) = {} of K => V) #

[View source]
def self.new(hash : Hash(K, V) = {} of K => V, &block : K -> V) #

[View source]
def self.new(e : Enumerable(Tuple(L, W))) forall L, W #

[View source]

Instance Method Detail

def delete(key : K) #
Description copied from class Immutable::Map(K, V)

Returns a modified copy of the map with the key-value pair removed. If the key is not existing, it raises KeyError

m  = Immutable::Map[{:foo => 123, :bar => 321 }]
m2 = m.delete(:bar) # => Map {:foo => 123}
m                   # => Map {:foo => 123, bar: 321}

[View source]
def merge(hash : Hash(K, V)) #
Description copied from class Immutable::Map(K, V)

Returns a new map with the keys and values of this map and the given hash combined. A value in the given hash takes precedence over the one in this map.

map = Immutable::Map[{"foo" => "bar"}]
merged = map.merge({"baz" => "qux"})
merged # => Map {"foo" => "bar", "baz" => "qux"}
map    # => Map {"foo" => "bar"}

[View source]
def merge(map : Map(K, V)) #
Description copied from class Immutable::Map(K, V)

Returns a new map with the keys and values of this map and the given map combined. A value in the given map takes precedence over the one in this map.

map = Immutable::Map[{"foo" => "bar"}]
merged = map.merge(Immutable::Map[{"baz" => "qux"}])
merged # => Map {"foo" => "bar", "baz" => "qux"}
map    # => Map {"foo" => "bar"}

[View source]
def merge(hash : Hash(L, W)) forall L, W #

[View source]
def merge(map : Map(L, W)) forall L, W #

[View source]
def persist! #

[View source]
def set(key : K, value : V) #
Description copied from class Immutable::Map(K, V)

Returns a modified copy of the map where key is associated to value

m  = Immutable::Map[{:foo => 123}]
m2 = m.set(:bar, 321) # => Map {:foo => 123, :bar => 321}
m                     # => Map {:foo => 123}

[View source]