Thanks all for the resources! 

So just to confirm, that (ref) is the only way to hold "references" to 
objects (and not a "reference" to a new copy) in a slice, so that I can 
iterate over the original objects using the slice. Correct?

And In my tryref example, the issue is with the append and that it is 
making a copy of the original objects at a state when it had no references, 
is that right?

It would be nice to see some documentation expanded out to more complex 
types. I understand the docs should be simple and easy to understand and it 
may not matter as all types are handled the same (copy-by-value), but in 
practice the difference can introduce bugs or confusion. To clarify, in 
most cases it won't matter when using a copy of an int, but could if the 
function needs to reference an exact object (in that case a pointer is 
needed).

Related, is there a doc explaining what happens (the rules of copy-by-value 
method) when you pass an argument to a function in the various cases of a 
primitive and complex type? 





On Sunday, November 13, 2016 at 6:57:07 AM UTC-8, Rob 'Commander' Pike 
wrote:
>
> There's also https://blog.golang.org/slices
>
> On Sun, Nov 13, 2016 at 1:50 AM, Jan Mercl <0xj...@gmail.com <javascript:>
> > wrote:
>
>>
>> On Sun, Nov 13, 2016 at 10:45 AM <question....@gmail.com <javascript:>> 
>> wrote:
>>
>> > Also I understand that everything is pass-by-value, but what exactly is 
>> getting passed for tryref that retains the id but not the slice of pointers?
>>
>> The answer can be found in the article linked by Volker earlier in this 
>> thread. I can recommend reading it as well.
>> -- 
>>
>> -j
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to