reticulated icon indicating copy to clipboard operation
reticulated copied to clipboard

option types with None?

Open bennn opened this issue 9 years ago • 2 comments

Is there a "maybe None" type in reticulated that would let me type the following (without Dyn)?

def div(n1:int, n2:int)->int:
  if n2 == 0:
    return None
  else:
    return n1 / n2

If not, can we add this? (The other option I see is making a Option class with Some val and None subtypes, but I don't want to refactor functions like div.)

bennn avatar Jun 08 '16 17:06 bennn

I also don't want to raise an exception

bennn avatar Jun 08 '16 17:06 bennn

There is not such a type (yet!).

On Wed, Jun 8, 2016 at 1:40 PM, Benjamin Greenman [email protected] wrote:

Is there a "maybe None" type in reticulated that would let me type the following (without Dyn)?

def div(n1:int, n2:int)->int: if n2 == 0: return None else: return n1 / n2

If not, can we add this? (The other option I see is making a Option class with Some val and None subtypes, but I don't want to refactor functions like div.)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mvitousek/reticulated/issues/28, or mute the thread https://github.com/notifications/unsubscribe/ABjedZf51nDpA0W6NAdk3Z1TawZdzDapks5qJv52gaJpZM4IxNzg .

mvitousek avatar Jun 08 '16 17:06 mvitousek