struct SimpleHash(K, V)

Defined in:

simple_hash.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from struct Struct

==(other : self) : Bool ==, hash : Int32 hash, inspect(io : IO) : Nil inspect, to_s(io) to_s

Instance methods inherited from struct Value

! !, ==(other) ==, nil? nil?

Instance methods inherited from class Object

! !, !=(other) !=, !~(other) !~, ==(other) ==, ===(other) ===, =~(other) =~, class class, clone clone, crystal_type_id crystal_type_id, dup dup, hash hash, inspect
inspect(io : IO)
inspect
, itself itself, not_nil! not_nil!, tap(&block) tap, to_json to_json, to_pretty_json(io : IO)
to_pretty_json
to_pretty_json
, to_s
to_s(io : IO)
to_s
, to_yaml(io : IO)
to_yaml
to_yaml
, try(&block) try

Class methods inherited from class Object

==(other : Class) ==, ===(other) ===, cast(other) : self cast, from_json(string_or_io) from_json, from_yaml(string : String) from_yaml, hash hash, inspect(io) inspect, name : String name, to_s(io) to_s

Class Method Detail

def self.new(values) #

[View source]
def self.new #

[View source]

Instance Method Detail

def [](key) #

[View source]
def []=(key : K, value : V) #

[View source]
def []?(key) #

[View source]
def delete(key) #

[View source]
def dup #

[View source]
def each(&block) #

[View source]
def each_key(&block) #

[View source]
def each_value(&block) #

[View source]
def each_with_object(memo, &block) #

Iterates the given block for each element with an arbitrary object given, and returns the initially given object.

evens = (1..10).each_with_object([] of Int32) { |i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

[View source]
def fetch(key, &block) #

[View source]
def has_key?(key) #

[View source]
def inspect(io : IO) #

[View source]
def keys #

[View source]
def object_id #

[View source]
def reject(&block : K, V -> U) #

Returns a new hash consisting of entries for which the block returns false.

h = {"a" => 100, "b" => 200, "c" => 300}
h.reject { |k, v| k > "a" } # => {"a" => 100}
h.reject { |k, v| v < 200 } # => {"b" => 200, "c" => 300}

[View source]
def reject!(&block : K, V -> U) #

Equivalent to Hash#reject, but makes modification on the current object rather that returning a new one. Returns nil if no changes were made.


[View source]
def select(&block : K, V -> U) #

Returns a new hash consisting of entries for which the block returns true.

h = {"a" => 100, "b" => 200, "c" => 300}
h.select { |k, v| k > "a" } # => {"b" => 200, "c" => 300}
h.select { |k, v| v < 200 } # => {"a" => 100}

[View source]
def select!(&block : K, V -> U) #

Equivalent to Hash#select but makes modification on the current object rather that returning a new one. Returns nil if no changes were made


[View source]
def size #

[View source]
def to_s(io : IO) #

[View source]
def values #

[View source]