Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Pattern Matching for Java. Parent comment
sealed trait Either[A, B] final case class Left[A, B](a: A) extends Either[A, B] final case class Right[A, B](b: B) extends Either[A, B]
with derive4j:
@Data interface Either<A, B> { <X> X match(Function<A, X> left, Function<B, X> right); }
@Data interface Either<A, B> { interface Cases<X> { X left(A leftValue); X right(B rightValue); } <X> X match(Cases<X> cases); }
The real drawback of (any) java implementation is lack of TCO.
There are no comments on this comment yet.
with derive4j:
or, at your preference: So it is actually not much boilerplate.The real drawback of (any) java implementation is lack of TCO.