Skip to content

Commit

Permalink
Releasing v0.5.0: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcoffey committed Apr 14, 2024
1 parent 998b113 commit 247617c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ error handling.
go get github.com/sdcoffey/fn
```
## In this package
* [All](#All)
* [AllNonZero](#AllNonZero)
* [Any](#Any)
* [AnyNonZero](#AnyNonZero)
* [Chunk](#Chunk)
Expand All @@ -32,6 +34,38 @@ go get github.com/sdcoffey/fn
* [Zip](#Zip)


### All
All returns true if all items in the slice satisfy the predicate.

```go
func ExampleAll() {
positiveInts := []int{1, 2, 3}
allPositive := All(positiveInts, func(item int, index int) bool {
return item > 0
})

fmt.Println(allPositive)
// Output: true
}
```

### AllNonZero
AllNonZero is a helper function that returns true if all items in the slice
are not the zero value for their type.

```go
func ExampleAllNonZero() {
nonZeroInts := []string{"one", "two", "three"}
fmt.Println(AllNonZero(nonZeroInts))

zeroInts := []string{"", "", ""}
fmt.Println(AllNonZero(zeroInts))
// Output:
// true
// false
}
```

### Any
Any returns true if any item in the slice satisfies the predicate.

Expand Down

0 comments on commit 247617c

Please sign in to comment.