Documentation
¶
Index ¶
- func Associate[T any, K comparable, V any](collection []T, keyFn func(T) (K, V)) map[K]V
- func Contains[T comparable](collection []T, v T) bool
- func ContainsBy[T any](collection []T, predicate func(T) bool) bool
- func Find[T any](collection []T, predicate func(T) bool) (T, bool)
- func Keys[K comparable, V any](m map[K]V) []K
- func Must[T any](val T, err error) T
- func Ternary[T any](condition bool, ifTrue, ifFalse T) T
- func Without[T comparable](collection []T, exclude ...T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Associate ¶
func Associate[T any, K comparable, V any](collection []T, keyFn func(T) (K, V)) map[K]V
Associate converts a slice to a map by applying keyFn to each element.
func Contains ¶
func Contains[T comparable](collection []T, v T) bool
Contains reports whether v is present in collection.
func ContainsBy ¶
ContainsBy reports whether any element of collection satisfies predicate.
func Find ¶
Find returns the first element satisfying predicate and true, or the zero value and false if no element matches.
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
Keys returns the keys of the map in an unspecified order.
func Without ¶
func Without[T comparable](collection []T, exclude ...T) []T
Without returns a copy of collection with all occurrences of exclude removed.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.