std/named_tuple
import std/named_tuple to use it. Source: src/std/named_tuple.iyi at v0.18.0.
NamedTuple(T)struct, reopened
struct ::NamedTuple(T)
# Returns the value for *key*, or panics if missing.
def [](key : Symbol)
# Returns the value for string *key*, or panics if missing.
def [](key : String)
# Returns the value for *key*, or nil if missing.
def []?(key : Symbol)
def []?(key : String)
# Deep clone of this named tuple, as far as the values allow: each value
# whose type has `clone` is cloned and any other is kept as it is.
# Asking every value for `clone` refused `{a: 1, b: "x"}`: the prelude
# gives `clone` to neither `Int32` nor `String`, so only a named tuple of
# values that all had one compiled.
def clone
# Yields each key symbol in order.
def each_key(& : (Symbol -> Nil)) : Nil
# Yields each key, value, and integer index.
def each_with_index(offset : Int = 0) : Nil
# Fetches value for *key*, returning *default_value* if missing.
def fetch(key : Symbol, default_value)
def fetch(key : String, default_value)
# Fetches value for *key*, or yields to block if missing.
def fetch(key : Symbol)
def fetch(key : String)
# Returns true if the named tuple has the given string key.
def has_key?(key : String) : Bool
# Merges another named tuple with self. Entries in *other* overwrite matching keys.
def merge(other : NamedTuple)
def merge(**other : **U) forall U
# Creates a named tuple from keyword options.
def self.new(**options : **T)
# Merges self into other: self's values win on overlapping keys.
def reverse_merge(other : NamedTuple)
def reverse_merge(**other)
# Converts this named tuple into an Array of {Symbol, Value} pairs.
def to_a
# Converts this named tuple into a Hash.
def to_h
end
NamedTuple methods the prelude does not carry: dynamic key access, merge, clone, and conversion to Array/Hash.