Open nyanpasu64 opened 5 years ago
Just change this to return Nothing()
Seems like you're supposed to use the or_else()
method instead of get()
, but then why provide a get()
method anyway?
There is a similar issue also with obj.member = None; maybe(obj).member.get()
.
I think the root cause is maybe(None).get()
raises.
To me it's more logical to have maybe(None).get() == None
.
This can be done if we update the code to have maybe(None) == Something(None)
.
pip install pymaybe
maybe([None])[0].is_none()
is True.maybe([None])[0].get()
raises Exception, despite[None][0]
is None.maybe({'a': None})['a'].get()
raises Exception, despite{'a': None}['a']
is None.https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/
Despite being a maybe "implementation", this library fails to distinguish a missing element from a deliberate None value.