struct

Hash::View(K, V)

Inherits Iterable < Enumerable < Struct < Value < Object

A HashView is a read-only version of a Hash. This is useful to give access to a non-modifiable hash in a type-safe manner.

The functionality of HashView is limited by design, as it just delegates the non-writable methods to the enclosed hash.

arr = HashView.new({"a" => 1, "b" => 2})
arr.size        # => 2
arr["a"]        # => 1
arr.select "b"  # => {"b" => 2}
arr.select! "b" # does not compile
arr["c"] = 3    # does not compile

Constructors

new(hash : Hash(K, V) = {} of K => V)
Source

Instance methods

==(rhs : Hash(K, V)) : Bool
Source
==(rhs : self) : Bool
Source
[](*args, **options)
Source
[](*args, **options, &)
Source
[]?(*args, **options)
Source
[]?(*args, **options, &)
Source
compact(*args, **options)
Source
compact(*args, **options, &)
Source
dig(*args, **options)
Source
dig(*args, **options, &)
Source
dig?(*args, **options)
Source
dig?(*args, **options, &)
Source
each(*args, **options)
Source
each(*args, **options, &)
Source
each_key(*args, **options)
Source
each_key(*args, **options, &)
Source
each_value(*args, **options)
Source
each_value(*args, **options, &)
Source
empty?(*args, **options)
Source
empty?(*args, **options, &)
Source
fetch(*args, **options)
Source
fetch(*args, **options, &)
Source
first_key(*args, **options)
Source
first_key(*args, **options, &)
Source
first_key?(*args, **options)
Source
first_key?(*args, **options, &)
Source
first_value(*args, **options)
Source
first_value(*args, **options, &)
Source
first_value?(*args, **options)
Source
first_value?(*args, **options, &)
Source
has_key?(*args, **options)
Source
has_key?(*args, **options, &)
Source
has_value?(*args, **options)
Source
has_value?(*args, **options, &)
Source
inspect(io : IO) : Nil

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Source
invert(*args, **options)
Source
invert(*args, **options, &)
Source
key_for(*args, **options)
Source
key_for(*args, **options, &)
Source
key_for?(*args, **options)
Source
key_for?(*args, **options, &)
Source
keys(*args, **options)
Source
keys(*args, **options, &)
Source
last_key(*args, **options)
Source
last_key(*args, **options, &)
Source
last_key?(*args, **options)
Source
last_key?(*args, **options, &)
Source
last_value(*args, **options)
Source
last_value(*args, **options, &)
Source
last_value?(*args, **options)
Source
last_value?(*args, **options, &)
Source
merge(*args, **options)
Source
merge(*args, **options, &)
Source
pretty_print(*args, **options)
Source
pretty_print(*args, **options, &)
Source
proper_subset_of?(*args, **options)
Source
proper_subset_of?(*args, **options, &)
Source
proper_superset_of?(*args, **options)
Source
proper_superset_of?(*args, **options, &)
Source
reject(*args, **options)
Source
reject(*args, **options, &)
Source
select(*args, **options)
Source
select(*args, **options, &)
Source
size(*args, **options)
Source
size(*args, **options, &)
Source
subset_of?(*args, **options)
Source
subset_of?(*args, **options, &)
Source
superset_of?(*args, **options)
Source
superset_of?(*args, **options, &)
Source
to_a(*args, **options)
Source
to_a(*args, **options, &)
Source
to_h(*args, **options)
Source
to_h(*args, **options, &)
Source
to_s(*args, **options)
Source
to_s(*args, **options, &)
Source
transform_keys(*args, **options)
Source
transform_keys(*args, **options, &)
Source
transform_values(*args, **options)
Source
transform_values(*args, **options, &)
Source
values(*args, **options)
Source
values(*args, **options, &)
Source
values_at(*args, **options)
Source
values_at(*args, **options, &)
Source