Thanks a lot sir! On Saturday, April 30, 2022 at 4:56:44 PM UTC-4 vzdra...@gmail.com wrote:
> Here is a working version of the Get & Set methods without changing your > method signatures. https://go.dev/play/p/MAqFwVINvd8 > > On Saturday, April 30, 2022 at 2:43:31 PM UTC-6 sunto...@gmail.com wrote: > >> I've done many reading on Go generic method parameters, and it seems >> *somewhat* supported, like from >> >> https://markphelps.me/posts/trying-out-generics-in-go/ >> >> A generic Get() & Set() can be defined and used: >> >> ---------------------------- >> // Set sets the value. >> func (o *Optional[T]) Set(v T) { >> o.value = &v >> } >> >> ... >> >> Now the user of my library could write code like this: >> >> o := New(42) >> v, err := o.Get() >> ---------------------------- >> >> However, I was having a hard time trying to apply that to my following >> code: >> https://go.dev/play/p/p8FMYHEFRUK >> >> Is it possible to get its generic Get() & Set() function working (which >> is currently commented out)? >> >> Thanks >> >> -- 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/07680055-957e-408d-934e-fdabdcd5842fn%40googlegroups.com.