Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new method Concat #376

Merged
merged 5 commits into from
Jun 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update README.md
  • Loading branch information
samber committed Jun 29, 2024
commit 885bac9acba76d2f6eb370b3c59b5716f00edafd
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Supported helpers for slices:
- [CountValuesBy](#countvaluesby)
- [Subset](#subset)
- [Slice](#slice)
- [Concat](#concat)
- [Replace](#replace)
- [ReplaceAll](#replaceall)
- [Compact](#compact)
Expand Down Expand Up @@ -848,6 +849,21 @@ slice := lo.Slice(in, 4, 3)

[[play](https://go.dev/play/p/8XWYhfMMA1h)]

### Concat

Returns a new slice containing all the elements in collections. Concat conserves the order of the elements.

```go
slice := lo.Concat([]int{1, 2}, []int{3, 4})
// []int{1, 2, 3, 4}

slice := lo.Concat(nil, []int{1, 2}, nil, []int{3, 4}, nil)
// []int{1, 2, 3, 4}

slice := lo.Concat[int]()
// []int{}
```

### Replace

Returns a copy of the slice with the first n non-overlapping instances of old replaced by new.
Expand Down
Loading