Author: ghik Created: 07/01/16.
A typeclass which witnesses that type A
can be wrapped into trait or abstract class B
Like Opt but does have a counterpart for Some(null)
.
Like Option
but avoids boxing and treats null
as no value.
Like Opt but has better Java interop thanks to the fact that wrapped value has type A
instead of Any
.
Like Opt but has better Java interop thanks to the fact that wrapped value has type A
instead of Any
.
For example, Scala method defined like this:
def takeMaybeString(str: OptRef[String]): Unit
will be seen by Java as:
public void takeMaybeString(String str);
and null
will be used to represent absence of value.
This comes at the cost of A
having to be a nullable type. Also, empty value is represented internally using null
which unfortunately makes OptRef suffer from SI-7396 (hashCode
fails on OptRef.Empty
which means that you
can't add OptRef values into hash sets or use them as hash map keys).
Author: ghik Created: 07/01/16.
Author: ghik Created: 23/11/15.
Base trait for companion objects of sealed traits that serve as enums, i.e.
Base trait for companion objects of sealed traits that serve as enums, i.e. their only values are case objects. For example:
sealed trait SomeEnum object SomeEnum extends SealedEnumCompanion[SomeEnum] { case object FirstValue extends SomeEnum case object SecondValue extends SomeEnum case object ThirdValue extends SomeEnum // it's important to give explicit type here val values: List[SomeEnum] = caseObjects }
Base class for sealed enums which can be used as key type for a TypedMap.
Author: ghik Created: 21/04/16.
Author: ghik Created: 24/11/15.
Author: ghik Created: 11/12/15.
Like
Option
but avoids boxing and treatsnull
as no value. Therefore, there is no equivalent forSome(null)
.Author: ghik Created: 07/01/16.