Skip to content

Commit

Permalink
chore: update readme for First and FirstOrZeroValue functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alireza-Kiani committed May 12, 2024
1 parent c196b72 commit 93469fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ Supported search helpers:
- [Max](#max)
- [MaxBy](#maxby)
- [Last](#last)
- [First](#first)
- [FirstOrZeroValue](#firstorzerovalue)
- [Nth](#nth)
- [Sample](#sample)
- [Samples](#samples)
Expand Down Expand Up @@ -1988,6 +1990,25 @@ Returns the last element of a collection or error if empty.
last, err := lo.Last([]int{1, 2, 3})
// 3
```
### First

Returns the first element of a collection or error if empty.

```go
first, err := lo.First([]int{1, 2, 3})
// 1
```
### FirstOrZeroValue

Returns the first element of a collection or zero value if empty.

```go
first := lo.FirstOrZeroValue([]int{1, 2, 3})
// 1

first := lo.FirstOrZeroValue([]int{})
// 0
```

### Nth

Expand Down

0 comments on commit 93469fa

Please sign in to comment.