Sorry for typo and possible spam but correct example here:
type Foo<K, V> interface {
Get(key K) V
Set(key K, val V)
}
func foo() (int, Foo<string, int>) {
// Typo: foo := &Foo<string, int>{}
foo := &fooStruct<string, int>{}
// ...
foos := []Foo<K,V>{}
// ...
k := "London"
// ...
return 55, foo2(foos, 55, k)
}
// This code is type safe and reusable
foo2<K, V> (foos []Foo<K,V>, i int, key K) (V, Foo<K,V>) {
foo := foos[i]
return foo.Get(key), foo
}
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.