Hi Ahmed,
the line
*MyNode() = MyNode(0,0,MyNode[])*
is just to make life easier. It means that when you call
MyNode() without arguments it will set some default values
for you, in this case 0, 0 and MyNode[]
(MyNode[] is an empty Vector that can hold elements of type MyNode).
Adapting your type definition of
*type MyNode{T} data::Vector{T}*
* level::Int child :: Vector{MyNode} nchild :: Int*
*end*
*MyNode() = MyNode(Float64[], 0, MyNode[], 0)*
you could also define the following function:
*function add_children!(parentNode, nChildren)*
* data = Float64[] # do something with the data here, I dont know whats
needed..*
* level = parentNode.level + 1*
* for i in 1:nChildren*
* child = MyNode(data, level, MyNode[], 0)*
* push!(parentNode.child, child)*
* end*
* parentNode.nchild += nChildren*
*end*
*root = MyNode()*
*add_children!(root, 100)*
*for child in root.child*
* add_children!(child, 10)*
*end*