Skip to content

yurivish/LayerDicts.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LayerDicts

Build Status 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

About

Layered dictionary lookups for Julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%