Hallöchen!

'Axel Wagner' via golang-nuts writes:

> [...]
>
> What would this do?
>
> func F(s []any) {
>     s[0] = "Foo"
> }
> func main() {
>     s := []int{1,2,3,4}
>     F(s)
>     fmt.Println(s)
> }

I think most intuitive would be if this behaved as an implicit
instantiation of the function with the type passed to it.

If I replace the signature of F with “F[T []E, E any](s T)”, the
compiler complaints “IncompatibleAssign” at “s[0] = "Foo"”.  I can
do “fmt.Println(s[0])”, though.  This is what somebody coming to Go
freshly would expect.  (IMO)

Regards,
Torsten.

-- 
Torsten Bronger

-- 
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/87y1g8za4d.fsf%40physik.rwth-aachen.de.

Reply via email to