Skip to content

Commit 433d309

Browse files
author
Tim
committed
Improved documentation readability
1 parent a95b8d8 commit 433d309

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
## Functions
55
### 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.
78
```go
89
func IndexOf[Type comparable](array []Type, needle interface{}) int
910

@@ -18,7 +19,8 @@ func main() {
1819
```
1920

2021
### 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.
2224
```go
2325
func LastIndexOf[Type comparable](array []Type, needle interface{}) int
2426

@@ -34,7 +36,9 @@ func main() {
3436
```
3537

3638
### 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.
3842
```go
3943
func FindIndex[Type any](array []Type, callable func(item Type) bool) int
4044

@@ -51,7 +55,9 @@ func main() {
5155
```
5256

5357
### 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.
5561
```go
5662
func Find[Type any](array []Type, callable func(item Type) bool) interface{}
5763

@@ -68,7 +74,8 @@ func main() {
6874
```
6975

7076
### Contains
71-
Check if array contains an item
77+
Contains checks whether the array/slice contains the specified element.
78+
It returns true if the element is found, false otherwise.
7279
```go
7380
func Contains[Type comparable](array []Type, needle interface{}) bool
7481

@@ -83,7 +90,7 @@ func main() {
8390
```
8491

8592
### Flip
86-
Flips an array
93+
Flip reverses the order of elements in the array/slice and returns the modified array/slice.
8794
```go
8895
func Flip[Type any](array []Type) []Type
8996

@@ -98,7 +105,9 @@ func main() {
98105
```
99106

100107
### Map
101-
Apply the given function to each element
108+
Map applies the given function to each element in the array/slice and returns a new array/slice with the results.
109+
It takes the original array/slice and a callable function that accepts an item from the array/slice and returns a modified or transformed value.
110+
The function returns a new array/slice containing the transformed values.
102111
```go
103112
func Map[Type any](array []Type, callable func(item Type) Type) []Type
104113

@@ -115,7 +124,9 @@ func main() {
115124
```
116125

117126
### ForEach
118-
Apply the given function, does not have a return value
127+
ForEach applies the given function to each element in the array/slice without returning any results.
128+
It takes the original array/slice and a callable function that accepts an item from the array/slice.
129+
The function iterates over each element and applies the given function to it.
119130
```go
120131
func ForEach[Type any](array []Type, callable func(item Type))
121132

@@ -130,7 +141,10 @@ func main() {
130141
```
131142

132143
### Slice
133-
Slice an array
144+
Slice returns a portion of the array/slice.
145+
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.
134148
```go
135149
func Slice[Type any](array []Type, size int, start int) []Type
136150

@@ -146,7 +160,8 @@ func main() {
146160
*Also contains SliceFrom and SliceTo*
147161

148162
### Merge
149-
Merge 2 or more slices together
163+
Merge merges multiple slices into a single slice.
164+
It takes variable arguments representing the slices to be merged and returns the merged slice.
150165
```go
151166
func Merge[Type any](slices ...[]Type) []Type
152167

0 commit comments

Comments
 (0)