arrays: fix examples for find_first and find_last (#19153)

This commit is contained in:
Turiiya 2023-08-17 06:15:37 +02:00 committed by GitHub
parent d0e605750b
commit 6df8ca212b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -681,7 +681,7 @@ pub fn carray_to_varray[T](c_array_data voidptr, items int) []T {
// find_first returns the first element that matches the given predicate
// returns `none`, if there is no match found
// Example: arrays.find_first([1, 2, 3, 4, 5], fn (arr int) bool { arr == 3}) // => 3
// Example: arrays.find_first([1, 2, 3, 4, 5], fn (i int) bool { return i == 3 })? // => 3
pub fn find_first[T](array []T, predicate fn (elem T) bool) ?T {
if array.len == 0 {
return none
@ -696,7 +696,7 @@ pub fn find_first[T](array []T, predicate fn (elem T) bool) ?T {
// find_last returns the last element that matches the given predicate
// returns `none`, if there is no match found
// Example: arrays.find_last([1, 2, 3, 4, 5], fn (arr int) bool { arr == 3}) // => 3
// Example: arrays.find_last([1, 2, 3, 4, 5], fn (i int) bool { return i == 3})? // => 3
pub fn find_last[T](array []T, predicate fn (elem T) bool) ?T {
if array.len == 0 {
return none