LayerDicts.jl

Layered dictionary lookups for Julia
Author invenia
Popularity
9 Stars
Updated Last
1 Year Ago
Started In
December 2017

LayerDicts

CI CodeCov

LayerDict is an Associative type that wraps a series of other associatives (e.g. Dicts). When performing a lookup, a LayerDict will look through its associatives in the order they were passed to the constructor until it finds a match. LayerDicts are immutable—you cannot call setindex! on them. However, you can update its wrapped associatives and those changes will be reflected in future lookups.

Example

using LayerDicts

dict1 = Dict{Symbol, Int}(:foo => 1, :bar => 1)
dict2 = Dict{Symbol, Int}()
dict3 = Dict{Symbol, Int}(:bar => 3, :baz => 3)

ld = LayerDict([dict1, dict2, dict3])
@assert ld[:foo] == 1
@assert ld[:bar] == 1
@assert ld[:baz] == 3
ld[:quuz]  # throws a KeyError

Required Packages

No packages found.