Go has no notion of "reference type". And pointer types are just
that pointers. Never think about pointer types as reference types.
There are values and pointers to values.
Slices are a bit complicated: Please read
https://blog.golang.org/go-slices-usage-and-internals
carefully. It explains everything you need to know better
than I could do here.

V.

Am Sonntag, 13. November 2016 05:52:49 UTC+1 schrieb question....@gmail.com:
>
> To keep a reference to a set of objects in a slice, must it be of type 
> []*T ?
>
> Is there a more elegant way to handle the following example?
>
> https://play.golang.org/p/73lfAntNzb
>
> tryref.id is an immutable value type and try.others is a reference type 
> correct? can you explain why the id is copied properly but the reference to 
> the object as well as tryref.others are not?
>
> I assume its because golang is pass by value and the type of tryref.others 
> is not a pointer so when appending an object it creates a new instance.
>
>

-- 
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