Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [either]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
24 votes
3 answers
7k views

Why use Either over (checked) Exception?

Not too long ago I started using Scala instead of Java. Part of the "conversion" process between the languages for me was learning to use Eithers instead of (checked) Exceptions. I've been coding this ...
Eyal Roth's user avatar
  • 603
4 votes
2 answers
2k views

Transform Either types in Scala

I have an Either type e.g. Either[A, B] but I want an Either[X, Y] by using two functions A => X and B => Y. I can do that with fold: val myEither: Either[A, B] = ... myEither.fold( a => ...
valenterry's user avatar
  • 2,429
7 votes
1 answer
842 views

Why are Scala's Either and Option types not interfaces/traits but classes?

I wanted to create a class CompileResult, that can be treated like an Either type but has some additional useful methods. It should be a CompileSuccess or a CompileFailure (which, too, has some ...
valenterry's user avatar
  • 2,429
5 votes
1 answer
382 views

Advantages and drawbacks of different ways using Either-types [closed]

I am writing software for compiling programs. Therefore have a Compiler that compiles a given sourcecode. It then returns a CompileResult that is similiar to an Either type (it is actually internally ...
valenterry's user avatar
  • 2,429