class Immutable::Map::Transient(K, V)
- Immutable::Map::Transient(K, V)
- Immutable::Map(K, V)
- Reference
- Object
Defined in:
immutable/map.crConstructors
- .new(hash : Hash(K, V) = {} of K => V)
- .new(hash : Hash(K, V) = {} of K => V, &block : K -> V)
- .new(e : Enumerable(Tuple(L, W))) forall L, W
Instance Method Summary
-
#delete(key : K)
Returns a modified copy of the map with the key-value pair removed.
-
#merge(hash : Hash(K, V))
Returns a new map with the keys and values of this map and the given hash combined.
-
#merge(map : Map(K, V))
Returns a new map with the keys and values of this map and the given map combined.
- #merge(hash : Hash(L, W)) forall L, W
- #merge(map : Map(L, W)) forall L, W
- #persist!
-
#set(key : K, value : V)
Returns a modified copy of the map where key is associated to value
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
Instance Method Detail
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}
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"}
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"}
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}