Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Maybe
- ...
- end
- class Left
- ...
- end
- class Right
- ...
- end
- def more_than_zero?(num)
- if num.kind_of?(Integer)
- Right[num > 0 ? true : false]
- else
- Left['only integers allowed here']
- end
- end
- result = more_than_zero(3)
- Maybe[result].
- on(Left, -> (res) { p "Error: #{res}" }).
- on(Right, -> (res) { p "Result: #{res}"}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement