Sign in
Log inSign up
Gaurav Shukla

11 likes

·

40 reads

6 comments

Gemma Black
Gemma Black
Apr 23, 2023

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?

1
·
·4 replies
Gaurav Shukla
Gaurav Shukla
Author
·Apr 23, 2023

Yeah! For sure Thanks for your suggestion

4
·
Gaurav Shukla
Gaurav Shukla
Author
·Apr 25, 2023

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.

1
·
Gemma Black
Gemma Black
Apr 25, 2023

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.

1
·
Gaurav Shukla
Gaurav Shukla
Author
·Apr 25, 2023

Anytime! I am happy to help you.

·
Sarika Kushwaha
Sarika Kushwaha
Apr 22, 2023

nice💫

·