#Changing struct value pointers of struct initialization that are stored in a slice
8 messages · Page 1 of 1 (latest)
are you sure? sorry, but pased on past experience, if you're just going to edit the code as if the error wasn't there, i have doubts that you're running things correctly to test :p
okay. the main problem here is that when you construct the slice, you're making copies of test10 and test20, so the Child value no longer refers to the one in the slice, but the original test10
you could consider making the slice a slice of pointers rather than values, so there are only the original values that don't get copied
if it isn't clear why this is a problem, you could consider drawing a picture of it. i think that really helps with following the pointers
just remember that the slice values are distinct from test10 and test20
great 😁
my best underrated tactic from my teaching days