SymDict.jl

Dictionaries with Symbol keys.
Popularity
2 Stars
Updated Last
3 Years Ago
Started In
December 2015

SymDict

Convenience functions for dictionaries with Symbol keys.

Build Status

Create a Dict{Symbol,}:

@SymDict(a=1, b=2)

Dict{Symbol,Any}(:a=>1,:b=>2)

Capture local variables in a dictionary:

a = 1
b = 2
@SymDict(a,b)

Dict{Symbol,Any}(:a=>1,:b=>2)
a = 1
b = 2
@SymDict(a,b,c=3)

Dict{Symbol,Any}(:a=>1,:b=>2,:c=3)

Capture varags key,value arguments in a dictionary:

function f(x; option="Option", args...)
    @SymDict(x, option, args...)
end

f("X", foo="Foo", bar="Bar")

Dict{Symbol,Any}(:x=>"X",:option=>"Option",:foo=>"Foo",:bar=>"Bar")

Merge new entries into a dictionary:

d = @SymDict(a=1, b=2)
merge!(d, c=3, d=4)

Dict{Symbol,Any}(:a=>1,:b=>2,:c=3,:d=>4)

Convert to/from `Dict{AbstractString,}:

d = @SymDict(a=1, b=2)
d = stringdict(d)

Dict{String,Any}("a"=>1,"b"=>2)

d = symboldict(d)

Dict{Symbol,Any}(:a=>1,:b=>2)

Required Packages

No packages found.