@grmpyprogrammer@yac.grumpy-learning.com
Post #4420737
2026-08-06 14:51 UTC
I am working my way through Go-By-Example and I have to say that this way of declaring a function and it's parameters is not intuitive at all:
func SlicesIndex[S ~[]E, E comparable](s S, v E) int {}
I am looking at it and trying to figure out how to explain it in computer-English
"This function accepts an array and some other value you want to find inside that list and then returns the index"
Coming from PHP all I can think is "why do I need to do this"
Replies (1)
-
@Girgias@phpc.social 2026-08-06 15:02
@grmpyprogrammer@yac.grumpy-learning.com Not knowing any Go and staring at it for a bit I guess it's something like: `function SlicesIndex(non-empty-list $s, E $v): int {}` But I guess the `S ~[]` might mean more "a slice of a list" rather than non empty.