-
Notifications
You must be signed in to change notification settings - Fork 163
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
Binary #825
Comments
@llorllale/z please, pay attention to this issue |
@Vatavuk seems like overkill to me. Why not simple |
@Vatavuk btw, I believe you can currently do something similar using |
@llorllale I don't see how can we do this with Although, one if (condition1.test()) {
action1.trigger();
}
else if(condition2.test()) {
action2.trigger();
} This can be rewritten using new Or(
new Binary(() -> condition1.test(), () -> action1.trigger()),
new Binary(() -> condition2.test(), () -> action2.trigger())
).value(); |
@Vatavuk one of the ctors you proposed was |
@llorllale just to provide more usage options, the result of |
@Vatavuk I don't see a reason to provide that ctor with scalar that will be ignored.. Everything else you've said sounds great though. |
@llorllale you are right, we can drop that ctor. I thought I have an example of such a usage but nothing rational comes in to my mind. |
@llorllale I remembered now, we need scalar in ctor if we want to throw checked exceptions. new Binary(
condition,
() -> {throw new IOException(msg);}
) |
@0crat in |
@llorllale Job #825 is now in scope, role is |
@llorllale Hey. This issue has been covered in PR #1054. Could you please close this issue? |
The job #825 is now out of scope |
We currently have
Ternary
which is equivalent toif then else
.I propose to create
Binary
that would be equivalent toif then
forsituations when a user needs to execute a specific action for given condition.
Binary
should:- implement
Scalar<Boolean>
- provide two ctors:
(Scalar<Boolean> condition, Scalar<T> scalar)
and(Scalar<Boolean> condition, Runnable runnable)
- return true if condition is met and action is triggered
The text was updated successfully, but these errors were encountered: