I’m trying to add members to my struct, but get:
BoundsError: attempt to access 0-element Array{Node,1} at index [1]
mutable struct Node
i::Int
j::Int
floor::Bool
neighbors::Array{Node}
color::Union{String,Nothing}
distance::Union{Int,Nothing}
predecessor::Union{Node,Nothing}
end
Node(i, j, floor=true) = Node(i, j, floor, [], nothing, nothing, nothing)
A matrix called nodearray is full of initialized nodes, which currently has member neighbors initialized to ‘nothing’
nodearray[i,j].neighbors[n] = Node(i-1,j)
I am not able to add nodes as neighbors. Why?