Skip to content

Commit

Permalink
rename lo.Bind to lo.Partial
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Jul 3, 2022
1 parent e00a624 commit 828393e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Adding:
- lo.FromPtr
- lo.IsEmpty
- lo.Compact
- lo.ToPairs: alias to lo.Entries
- lo.FromPairs: alias to lo.FromEntries
- lo.Partial

Change:

Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ Type manipulation helpers:
- Empty
- IsEmpty
- Coalesce
- Bind

Function helpers:

- Partial

Concurrency helpers:

Expand Down Expand Up @@ -1467,14 +1470,19 @@ result, ok := lo.Coalesce[*string](nil, nilStr, &str)
// &"foobar" true
```

### Bind
### Partial

Returns new function that, when called, has its first argument set to the provided value.

```go
add := func(x, y int) int { return x + y }
f := Bind(add, 5)
f := lo.Partial(add, 5)

f(10)
// 15

f(42)
// 47
```

### Attempt
Expand Down
4 changes: 2 additions & 2 deletions func.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lo

// Bind returns new function that, when called, has its first argument set to the provided value.
func Bind[T1, T2, R any](f func(T1, T2) R, arg1 T1) func(T2) R {
// Partial returns new function that, when called, has its first argument set to the provided value.
func Partial[T1, T2, R any](f func(T1, T2) R, arg1 T1) func(T2) R {
return func(t2 T2) R {
return f(arg1, t2)
}
Expand Down

0 comments on commit 828393e

Please sign in to comment.