You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Java API of PartitionWith takes a function that yields a scala.Either. Constructing that from Java is cumbersome. Either.cond comes close but by-name laziness is not retained.
I would like to replace the Either with something else, but what should it be?
I see one important benefit: clarity about the purpose of the split, by allowing a concise, atomic formulation of the difference between the two outputs. You cannot specify both map operations in a one-liner.
Another (possibly less convincing) argument: if the Either reduces the size of the input element, it saves you from passing a "full" element to another stage, only to reduce it there with a map, as you would with Partition.
A third, completely arbitrary and subjective reason would be that my highest-voted StackOverflow answer concerns PartitionWith 😉
For the Java API I'd suggest creating a custom class, PartitionWith.Output<A, B> with clear factory methods such as PartitionWith.selectLeft(A element), PartitionWith.selectRight(B element).
The Java API of
PartitionWith
takes a function that yields ascala.Either
. Constructing that from Java is cumbersome.Either.cond
comes close but by-name laziness is not retained.I would like to replace the
Either
with something else, but what should it be?Supplier
s?Either
from a Java library like cyclops-react?The text was updated successfully, but these errors were encountered: