I’m trying to create a tree class using Dicts. The base struct is:
mutable struct MyNode
name::String
information::Tuple
children::Dict{String, MyNode}
end
I have a constructor:
MyNode(name::String) = MyNode(name, (), Dict{String, MyNode}())
If I try to construct a MyNode from the REPL like so:
> tree1 = MyNode("root", (), Dict{String, MyNode}())
it works. But if I try to use the constructor I get an error:
> tree = MyNode("root")
ERROR: MethodError: Cannot `convert` an object of type Type{Dict{String,MyNode}} to an object of type Dict{String,MyNode}
This may have arisen from a call to the constructor Dict{String,MyNode}(...),
since type constructors fall back to convert methods.
What am I doing wrong?