On Fri, 2023-10-20 at 11:56 +0700, Nurahmadie Nurahmadie wrote:
> why is there no, type coercion, as you said, that allow the new type
> to be acknowledged as its underlying type? which will not be a
> question if otherwise Go has mechanism to allow methods to be
> attached to foreign types.

There is something like this, if you accept the use of interfaces
instead of concrete types (simplifying here).

You can make a `type T2 struct { T1 }` that has all the methods of T1
and whatever methods you add to T2 (note: Here be dragons!). This is
type embedding.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/91ba59cc036ea8c86c8eb8befdc5ba66a6e4f47a.camel%40kortschak.io.

Reply via email to