-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat(option): introduce option component #356
Conversation
Pull Request Test Coverage Report for Build 3554950291
💛 - Coveralls |
5c83ad5
to
be439b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice!
Just cross-linking here: I've provided a full example @ https://gist.github.com/Ocramius/368bd78c38cc5bb857e931801f6e4af7 Beware that
|
I was thinking with the addition of Dict\get<Tk, Tv>(dict<Tk, Tv> $d, Tk $k): Option<Tv> {
return Iter\contains_key($d, $k) ? Option\some($d[$k]) : Option\none();
}
Dict\get_typed<T>(dict<array-key, mixed> $d, array-key $k, Type\TypeInterface<T> $t): Option<T> {
return Iter\contains_key($d, $k) ? Option\some($t->coerce($d[$k])) : Option\none();
}
Vec\get<T>(vec<T> $v, int $k): Option<T> {
return Iter\contains_key($v, $k) ? Option\some($v[$k]) : Option\none();
}
Vec\get_typed<T>(vec<mixed> $v, int $k, Type\TypeInterface<T> $t): Option<T> {
return Iter\contains_key($v, $k) ? Option\some($t->coerce($v[$k])) : Option\none();
} |
To note, |
Signed-off-by: azjezz <azjezz@protonmail.com>
Discussed the open topics in this PR with @azjezz. There is nothing blocking that is stopping us from merging and releasing this PR. We can always take in additional improvements once people start using this component and start seeing better ways to do things. |
Signed-off-by: azjezz azjezz@protonmail.com