deterministic
deterministic copied to clipboard
Pattern matching on Maybe
I would like to be able to do somehting like this
Maybe(nil).match do
Some(s) { |v| s }
None(n) { |v| SomeObject.new }
end #=> SomeObject.new
Is this possible/is there a better pattern than this for having this behavior?
did you try Maybe(nil).value_or SomeObject.new ?
Piotr
On 20 Aug 2015, at 00:55, Ian Ker-Seymer [email protected] wrote:
I would like to be able to do somehting like this
Maybe(nil).match do Some(s) { |v| s } None(n) { |v| SomeObject.new } end Is this possible/is there a better pattern than this for having this behavior?
— Reply to this email directly or view it on GitHub.