Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option value design #172

Closed
bvssvni opened this issue May 16, 2016 · 0 comments
Closed

Option value design #172

bvssvni opened this issue May 16, 2016 · 0 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented May 16, 2016

Dyon has no null value, but uses some(val) and none(). It has a lot of common with result value, but there are a few differences.

  • some(x)
  • none()
  • unwrap(some(x)) returns x
  • none()? propagates an error, returning from the function

The type of option is opt (any type) and opt[T].

This is designed for:

  • Explicitly declare when a value is optional
  • Check when mutating a variable that it also is optional
  • Convenient for debugging
  • Common way of handling errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant