11 likes
·
41 reads
6 comments
I haven't started with Go yet so this was helpful.
Would this remove the pointer/reference then from the ptr
variable to x
...
ptr = 21
... when the star syntax is not used?
Yeah! For sure Thanks for your suggestion
I haven't seen your reply coz I was busy. No, assigning a value to a pointer variable in Go without using the dereferencing operator *
only changes the value of the pointer itself, not the value pointed to by the pointer. To change the value of the pointed-to variable, you need to dereference the pointer using the *
operator.
No worries and thanks Gaurav Shukla. I like to read these articles on my phone sometimes and I could have just tested it on a computer. But thank you for the explanation and theory.
Anytime! I am happy to help you.
nice💫