Files
lo/docs/data/it-hasprefix.md
T
2025-10-08 19:35:53 +02:00

956 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
HasPrefix hasprefix it/find.go#L49 it find
func HasPrefix[T comparable](collection iter.Seq[T], prefix ...T) bool
https://go.dev/play/p/3QbJK4hd-o
it#find#hasprefix
core#slice#hasprefix
it#find#hassuffix
20

Returns true if the collection has the specified prefix. The prefix can be specified as multiple arguments.

Examples:

seq := func(yield func(int) bool) {
    _ = yield(1)
    _ = yield(2)
    _ = yield(3)
    _ = yield(4)
}
hasPrefix := it.HasPrefix(seq, 1, 2)
// hasPrefix == true
seq := func(yield func(string) bool) {
    _ = yield("hello")
    _ = yield("world")
}
hasPrefix := it.HasPrefix(seq, "hello")
// hasPrefix == true
seq := func(yield func(int) bool) {
    _ = yield(1)
    _ = yield(2)
    _ = yield(3)
}
hasPrefix := it.HasPrefix(seq, 2, 3)
// hasPrefix == false