Skip to content

Instantly share code, notes, and snippets.

@arindam89
Created April 25, 2020 10:03
Show Gist options
  • Save arindam89/6f4d9e38645e23ab5c5ec3f7fc3cf01c to your computer and use it in GitHub Desktop.
Save arindam89/6f4d9e38645e23ab5c5ec3f7fc3cf01c to your computer and use it in GitHub Desktop.
Either Naive Example
// = Right(result) or Left(exception)
Either<Exception, Integer> divideEither(Integer dividend, Integer divisor) {
return Either.right(dividend / divisor);
}
@Test
public void createEither() {
System.out.println(divideEither(10,2));
System.out.println(divideEither(10,0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment