Skip to content

Commit eabd99b

Browse files
author
Tom Godkin
committed
Fix ExampleMap test
1 parent 3d12c84 commit eabd99b

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

option/option_test.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,16 @@ func ExampleOption_Value() {
7373
}
7474

7575
func ExampleMap() {
76-
posOnly := func(x int) option.Option[int] {
77-
if x < 0 {
78-
return option.None[int]()
79-
}
80-
81-
return option.Some(x)
82-
}
83-
84-
doubleNum := func(x int) int {
76+
double := option.Map(func(x int) int {
8577
return x * 2
86-
}
78+
})
8779

88-
optDouble := option.Map(doubleNum)
80+
fmt.Println(double(option.None[int]()))
81+
fmt.Println(double(option.Some(25)))
8982

90-
n := posOnly(-5)
91-
p := posOnly(25)
92-
93-
resultN := optDouble(n)
94-
resultP := optDouble(p)
95-
96-
fmt.Println(resultN) // option.None
97-
fmt.Println(resultP) // option.Some(50)
83+
// Output:
84+
// None
85+
// Some(50)
9886
}
9987

10088
func TestSomeStringer(t *testing.T) {

0 commit comments

Comments
 (0)