#Just another pointer question

14 messages · Page 1 of 1 (latest)

merry sequoia
#

that line does not panic

#

what is the value of allTreeNodes[0].Parent?

#

bingo

#

what is the value of allTreeNodes[0].Parent if you uncomment that line?

#

so, not nil

#

I don't know how to answer that, you just wrote two completely distinct lines of code, they do not do the same thing at all

#

well, what makes you think they should be doing the same thing?

#

think through what each line is doing

#

oh I misinterpreted what you meant, I apologize

#

node0 and nodes[0] are not the same value

#

it does not refer to the same thing, nodes[0] is a copy of node0, node1 and the corresponding copy at nodes[1] points to node0 not nodes[0]

#

I don't understand that sentence sunturtle
your problem is you assumed node0 and nodes[0] were the same thing when they weren't

#

ftr it is very rare to actually need a pointer to a slice

#

passing a slice does not copy the contents