Skip to content

Commit

Permalink
Merge pull request #4 from go-andiamo/remove-do-with
Browse files Browse the repository at this point in the history
Remove DoWith
  • Loading branch information
marrow16 committed Nov 11, 2022
2 parents 532d6e1 + cbea279 commit 18deeb0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ func main() {
</td>
<td><em>nothing</em></td>
</tr>
<tr>
<td>
<code>DoWith(f func(v T))</code><br>
if the value is present, calls the supplied function with the value<br>
<em>returns the original optional</em>
</td>
<td><code>Optional[T]</code></td>
</tr>
<tr>
<td>
<code>Filter(f func(v T) bool)</code><br>
Expand Down
10 changes: 0 additions & 10 deletions optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ func (o Optional[T]) OrElsePanic(v any) {
}
}

// DoWith if the value is present, calls the supplied function with the value
//
// Returns the original optional
func (o Optional[T]) DoWith(f func(v T)) Optional[T] {
if o.present {
f(o.value)
}
return o
}

// Filter if the value is present and calling the supplied filter function returns true, returns a new optional describing the value
//
// Otherwise returns an empty optional
Expand Down
17 changes: 0 additions & 17 deletions optional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,6 @@ func TestOptional_OrElsePanic(t *testing.T) {
})
}

func TestOptional_DoWith(t *testing.T) {
o := Empty[string]()
called := false
f := func(v string) {
called = true
}
o2 := o.DoWith(f)
require.False(t, called)
require.Equal(t, o, o2)

called = false
o = Of("aaa")
o2 = o.DoWith(f)
require.True(t, called)
require.Equal(t, o, o2)
}

func TestOptional_Filter(t *testing.T) {
o := Empty[string]()
called := false
Expand Down

0 comments on commit 18deeb0

Please sign in to comment.