File tree Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -73,28 +73,16 @@ func ExampleOption_Value() {
7373}
7474
7575func 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
10088func TestSomeStringer (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments