Standard library / slices
slices.EqualFunc()
Compares corresponding elements using a custom equality callback; slices of different element types are supported. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s1 | S1 | First slice to compare. |
| s2 | S2 | Second slice to compare. |
| eq | func(E1, E2) bool | Equality callback, true for equivalent elements. |
Return Value
bool
Compares corresponding elements using a custom equality callback; slices of different element types are supported.
Working Example
Example Snippetgo
package main
import ( "fmt" "slices")
func main() { fmt.Println(slices.EqualFunc([]string{"abc"}, []int{3}, func(s string, n int) bool { return len(s) == n }))}