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 extended functionality). However I can’t do that because Either
is an abstract class
and I don’t want to extend it but rather use delegation and have an Either
stored internally.
Why can’t the Scala compiler give pattern matching warning for nonsealed classes/traits?
If I use an unsealed trait
or abstract class
in Scala and then use pattern matching, I wonder, does the compiler not know at compile time for this particular patternmatch what possible implementations of this trait/class are available? So, if it does, could it not give pattern match warnings even though that the trait
/abstract class
is not sealed because he knows which types could be used, by checking all the possible dependencies/imports?
How to use scala case classes when delegation is needed
Let’s assume in our application we want to model cars. We also want to model a car repository where we store some registered cars. How should that be modeled in scala?
How to use scala case classes when delegation is needed
Let’s assume in our application we want to model cars. We also want to model a car repository where we store some registered cars. How should that be modeled in scala?
How to use scala case classes when delegation is needed
Let’s assume in our application we want to model cars. We also want to model a car repository where we store some registered cars. How should that be modeled in scala?
How to use scala case classes when delegation is needed
Let’s assume in our application we want to model cars. We also want to model a car repository where we store some registered cars. How should that be modeled in scala?
Is there a way to document required properties in traits (PHP)?
I’m fairly new to using traits in PHP and am wondering if there is a way to ensure that a class including a trait has particular properties.
Is there a way to document required properties in traits (PHP)?
I’m fairly new to using traits in PHP and am wondering if there is a way to ensure that a class including a trait has particular properties.