Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add Existential Operator #25

Open
akidee opened this Issue · 2 comments

2 participants

@akidee

In CS, this a feature I heavily use when writing templates, and it is very useful, since it makes your code more safe (because null/undefined will throw an error on accessing properties)

Example:

zip = lottery.drawWinner?().address?.zipcode
@weepy
Owner

I did once upon a time have one (actually I invented the one in CoffeeScript :)

I should be able to bring it back as I agree, it was useful. I decided to make it a little simple here though : more like a non-strict comparison with null, so your example would work like :

zip = (_ex = lottery.drawWinner()) != null && _ex.address && _ex.adress.zipcode
@weepy
Owner

I've put up a gist to explore the possibilities here :

https://gist.github.com/923899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.