get(collection, key, default)
Return the value stored for the given key, or the given default value if no mapping for the key is present.
tip Julia 1.7
For tuples and numbers, this function requires at least Julia 1.7.
Examples
julia> d = Dict("a"=>1, "b"=>2);
julia> get(d, "a", 3)
1
julia> get(d, "c", 3)
3
get(f::Union{Function, Type}, collection, key)
Return the value stored for the given key, or if no mapping for the key is present, return f()
. Use get!
to also store the default value in the dictionary.
This is intended to be called using do
block syntax
get(dict, key) do
# default value calculated here
time()
end
get(x::Nullable[, y])
Attempt to access the value of x
. Returns the value if it is present; otherwise, returns y
if provided, or throws a NullException
if not.
Examples
julia> get(Nullable(5))
5
julia> get(Nullable())
ERROR: NullException()
Stacktrace:
[1] get(::Nullable{Union{}}) at ./nullable.jl:102
get(sd,k,v)
Returns the value associated with key k
where sd
is a SortedDict, or else returns v
if k
is not in sd
. Time: O(c log n)
get(collection, key, default)
Return the value stored for the given key, or the given default value if no mapping for the key is present.
Examples
julia> d = RobinDict("a"=>1, "b"=>2);
julia> get(d, "a", 3)
1
julia> get(d, "c", 3)
3
get(f::Function, collection, key)
Return the value stored for the given key, or if no mapping for the key is present, return f()
. Use get!
to also store the default value in the dictionary.
This is intended to be called using do
block syntax
get(dict, key) do
# default value calculated here
time()
end
get(collection, key, default)
Return the value stored for the given key, or the given default value if no mapping for the key is present.
Examples
julia> d = OrderedRobinDict("a"=>1, "b"=>2);
julia> get(d, "a", 3)
1
julia> get(d, "c", 3)
3
get(f::Function, collection, key)
Return the value stored for the given key, or if no mapping for the key is present, return f()
. Use get!
to also store the default value in the dictionary.
This is intended to be called using do
block syntax
get(dict, key) do
# default value calculated here
time()
end
get(collection, key, default)
Return the value stored for the given key, or the given default value if no mapping for the key is present.
Examples
julia> d = SwissDict("a"=>1, "b"=>2);
julia> get(d, "a", 3)
1
julia> get(d, "c", 3)
3
get(f::Function, collection, key)
Return the value stored for the given key, or if no mapping for the key is present, return f()
. Use get!
to also store the default value in the dictionary.
This is intended to be called using do
block syntax
get(dict, key) do
# default value calculated here
time()
end