292892 (6) [Avatar] Offline
Page 109 says:

"Determining whether to use a value or pointer receiver can sometimes be confusing. There are some basic guidelines you can follow which come directly from the standard library."

It would be good to elaborate or point to these guidelines. I felt like I was left hanging a bit. From page 39, I guess the gist is if you're not modifying state then don't use pointer receivers. Still slightly confused. IE is it better to modify a bool by using a pointer receiver or to return a new bool from the func? I would suppose to use a pointer. I guess you would really only return values if something new that was created.
292892 (6) [Avatar] Offline
Reading on from Page 109 made it a bit more clear. I had put a bookmark in at that point and didn't continue on until later.
Bill Kennedy (68) [Avatar] Offline
Is there anything else specific you could suggest to help. I am wondering if I even keep the section. I am asked the question a lot and I am working on this material.
292892 (6) [Avatar] Offline
It made some more sense after reading on. IE Primitive types should be passed by value whereas reference types should be passed as pointer. In the general sense that is.

This stackoverflow what a bit helpful to me as well:

Bill Kennedy (68) [Avatar] Offline
To be clear, with the built-in and reference types, we don't want to share those by passing them with a pointer. Our struct type values yes, in many cases. But there are also cases where even then, passing a copy is a better option.
292892 (6) [Avatar] Offline
Hmm, I think I'm still slightly confused.

I read:


Perhaps I'm getting confused on two core things here. Passing by value or pointer to a method and passing by value or pointer for a method receiver. I think it will be the case of me having to go through some examples and figuring it out.
Bill Kennedy (68) [Avatar] Offline
Maybe we need to get on a hangout. This is good feedback but we should talk.