final class OrNullOps[A] extends AnyVal
It is common in interop code to model a value as A or null but not undefined
even though null and undefined may both mean "absent value." See |.merge
Many of these methods are already on js.|
but they appear to be left biased
as near as I can tell. I'm happy to delete these methods of that's not right
and those methods use js.UndefOr
in some way.
Note that chaining many js.|
together probably not work like you think and
sometimes its better to create a new target type then target implicits to
convert from each individual type (in the or) to the new target type. You
must model your type as A|Null
for this implicit to be picked up.
These methods exist to try and stop a conversion to UndefOr
or Option
as part of null processing. Hey! Every bit counts!
- Self Type
- OrNullOps[A]
- To do
Perhaps the force get methods should throw since
.orNull
exists in the scalajs standard library now.
- Alphabetic
- By Inheritance
- OrNullOps
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- def !?[B >: A](default: => B): B
getOrElse but less typing.
getOrElse but less typing.
- Annotations
- @inline()
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- def ??[B >: A](default: => B): B
getOrElse but less typing.
getOrElse but less typing.
- Annotations
- @inline()
- def ???[B >: A](other: |[B, Null]): |[B, Null]
Experimental
Experimental
- Annotations
- @inline()
- def ????[B >: A](next: (A) => |[B, Null]): |[B, Null]
Experimental
Experimental
- Annotations
- @inline()
- def absorbNull: A
Absorb the null and change A|Null => A.
Absorb the null and change A|Null => A. Value could still be null, which is valid in scala, but it will no longer by typed that way.
- Annotations
- @inline()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def collect[B](pf: PartialFunction[A, B]): |[B, Null]
- Annotations
- @inline()
- def contains[A1 >: A](elem: A1): Boolean
- final def exists(p: (A) => Boolean): Boolean
- Annotations
- @inline()
- def filter(p: (A) => Boolean): |[A, Null]
- Annotations
- @inline()
- def flatMap[B](f: (A) => |[B, Null]): |[B, Null]
- Annotations
- @inline()
- def flatten[B](implicit ev: <:<[A, |[B, Null]]): |[B, Null]
- def fold[B](ifNull: => B)(f: (A) => B): B
- Annotations
- @inline()
- final def forall(p: (A) => Boolean): Boolean
- Annotations
- @inline()
- def foreach[U](f: (A) => U): Unit
- Annotations
- @inline()
- def get: A
Get the value or throw if its null.
Get the value or throw if its null.
- Annotations
- @inline()
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- final def getOrElse[B >: A](default: => B): B
- Annotations
- @inline()
- def isDefined: Boolean
- Annotations
- @inline()
- def isEmpty: Boolean
- Annotations
- @inline()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isNotDefined: Boolean
- Annotations
- @inline()
- def iterator: Iterator[A]
- def knownSize: Int
- Annotations
- @inline()
- def map[B](f: (A) => B): |[B, Null]
- Annotations
- @inline()
- def merge: A
Collapse A|Null => A but the value may be null! You are on your own.
Collapse A|Null => A but the value may be null! You are on your own. Should be called
unsafeMerge
.- Annotations
- @inline()
- def orElse[B >: A](alternative: => |[B, Null]): |[B, Null]
- Annotations
- @inline()
- def orElse[B >: A](other: |[B, Null]): |[B, Null]
- Annotations
- @inline()
- final def orNull[A1 >: A]: A1
- Annotations
- @inline()
- def toList: List[A]
- def toNonNullOption: Option[A]
Convert an A|Null to a well formed Option.
Convert an A|Null to a well formed Option. Should we check or undefined?
- Annotations
- @inline()
- def toOption: Option[A]
Like .toNonNullOption
Like .toNonNullOption
- Annotations
- @inline()
- def toString(): String
- Definition Classes
- Any
- def toTruthy: Boolean
If Null, then false, else true.
If Null, then false, else true.
- Annotations
- @inline()
- def toTruthyOption: Option[A]
- Annotations
- @inline()
- def toTruthyUndefOr: UndefOr[A]
- Annotations
- @inline()
- def toUndefOr: UndefOr[A]
null => undefined, otherwise A.
null => undefined, otherwise A.
- Annotations
- @inline()
- def toUndefOrNull: UndefOr[|[A, Null]]
Uh-oh, thought it was
A|Null
but you need to say its ajs.UndefOr[A|Null]
because the docs were wrong :-).Uh-oh, thought it was
A|Null
but you need to say its ajs.UndefOr[A|Null]
because the docs were wrong :-).- Annotations
- @inline()
- final def unzip[A1, A2](implicit asPair: <:<[A, (A1, A2)]): (|[A1, Null], |[A2, Null])
- def withFilter(p: (A) => Boolean): WithFilter[A]
- Annotations
- @inline()
- final def zip[A1 >: A, B](that: |[B, Null]): |[(A1, B), Null]