You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-10Lines changed: 25 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
4
4
## Functions
5
5
### IndexOf
6
-
Returns the first index of the needle in the array
6
+
IndexOf returns the index of the first occurrence of the specified element in the array/slice.
7
+
If the element is not found, it returns -1.
7
8
```go
8
9
funcIndexOf[Type comparable](array []Type, needle interface{}) int
9
10
@@ -18,7 +19,8 @@ func main() {
18
19
```
19
20
20
21
### LastIndexOf
21
-
Returns the last index of the needle in the array
22
+
LastIndexOf returns the index of the last occurrence of the specified element in the array/slice.
23
+
If the element is not found, it returns -1.
22
24
```go
23
25
funcLastIndexOf[Type comparable](array []Type, needle interface{}) int
24
26
@@ -34,7 +36,9 @@ func main() {
34
36
```
35
37
36
38
### FindIndex
37
-
Find the index based on a lambda function
39
+
FindIndex returns the index of the first element in the array/slice that satisfies the given condition.
40
+
It takes the original array/slice and a callable function that accepts an item from the array/slice and returns a boolean value indicating whether the condition is met.
41
+
The function returns the index of the first matching element, or -1 if no element satisfies the condition.
38
42
```go
39
43
funcFindIndex[Type any](array []Type, callable func(item Type) bool) int
40
44
@@ -51,7 +55,9 @@ func main() {
51
55
```
52
56
53
57
### Find
54
-
Find the item based on a lambda function
58
+
Find returns the first element in the array/slice that satisfies the given condition.
59
+
It takes the original array/slice and a callable function that accepts an item from the array/slice and returns a boolean value indicating whether the condition is met.
60
+
The function returns the first matching element, or nil if no element satisfies the condition.
It takes the original array/slice, a size indicating the number of elements to include, and a start index.
146
+
The function returns a new array/slice containing elements from the original array/slice, starting from the given index and including the specified number of elements.
147
+
If the start index is beyond the array bounds, an empty slice is returned.
0 commit comments