mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
arrays: fix examples for find_first
and find_last
(#19153)
This commit is contained in:
parent
d0e605750b
commit
6df8ca212b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user