Open tomohavvk opened 4 months ago
After the first touch of Option type I was confused how the Map is implemented.
Option
Map
In my understanding of functional programming the Map should be applied only for a value and return the value, and never return the no-value.
For case when need to apply function for a value and return Some or None the FlatMap should be used.
Some
None
FlatMap
Before:
Some(1). Map(func(value int) (int, bool) { return value + 21, true })
After:
Some(1). Map(func(value int) int { return value + 21 })
Since this introduces a breaking change, we must wait for v2.
After the first touch of
Option
type I was confused how theMap
is implemented.In my understanding of functional programming the
Map
should be applied only for a value and return the value, and never return the no-value.For case when need to apply function for a value and return
Some
orNone
theFlatMap
should be used.Before:
After: