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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OrNullOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new OrNullOps(a: |[A, Null])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. def !?[B >: A](default: => B): B

    getOrElse but less typing.

    getOrElse but less typing.

    Annotations
    @inline()
  3. final def ##: Int
    Definition Classes
    Any
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  5. def ??[B >: A](default: => B): B

    getOrElse but less typing.

    getOrElse but less typing.

    Annotations
    @inline()
  6. def ???[B >: A](other: |[B, Null]): |[B, Null]

    Experimental

    Experimental

    Annotations
    @inline()
  7. def ????[B >: A](next: (A) => |[B, Null]): |[B, Null]

    Experimental

    Experimental

    Annotations
    @inline()
  8. 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()
  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. final def collect[B](pf: PartialFunction[A, B]): |[B, Null]
    Annotations
    @inline()
  11. def contains[A1 >: A](elem: A1): Boolean
  12. final def exists(p: (A) => Boolean): Boolean
    Annotations
    @inline()
  13. def filter(p: (A) => Boolean): |[A, Null]
    Annotations
    @inline()
  14. def flatMap[B](f: (A) => |[B, Null]): |[B, Null]
    Annotations
    @inline()
  15. def flatten[B](implicit ev: <:<[A, |[B, Null]]): |[B, Null]
  16. def fold[B](ifNull: => B)(f: (A) => B): B
    Annotations
    @inline()
  17. final def forall(p: (A) => Boolean): Boolean
    Annotations
    @inline()
  18. def foreach[U](f: (A) => U): Unit
    Annotations
    @inline()
  19. def get: A

    Get the value or throw if its null.

    Get the value or throw if its null.

    Annotations
    @inline()
  20. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  21. final def getOrElse[B >: A](default: => B): B
    Annotations
    @inline()
  22. def isDefined: Boolean
    Annotations
    @inline()
  23. def isEmpty: Boolean
    Annotations
    @inline()
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def isNotDefined: Boolean
    Annotations
    @inline()
  26. def iterator: Iterator[A]
  27. def knownSize: Int
    Annotations
    @inline()
  28. def map[B](f: (A) => B): |[B, Null]
    Annotations
    @inline()
  29. 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()
  30. def orElse[B >: A](alternative: => |[B, Null]): |[B, Null]
    Annotations
    @inline()
  31. def orElse[B >: A](other: |[B, Null]): |[B, Null]
    Annotations
    @inline()
  32. final def orNull[A1 >: A]: A1
    Annotations
    @inline()
  33. def toList: List[A]
  34. 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()
  35. def toOption: Option[A]

    Like .toNonNullOption

    Like .toNonNullOption

    Annotations
    @inline()
  36. def toString(): String
    Definition Classes
    Any
  37. def toTruthy: Boolean

    If Null, then false, else true.

    If Null, then false, else true.

    Annotations
    @inline()
  38. def toTruthyOption: Option[A]
    Annotations
    @inline()
  39. def toTruthyUndefOr: UndefOr[A]
    Annotations
    @inline()
  40. def toUndefOr: UndefOr[A]

    null => undefined, otherwise A.

    null => undefined, otherwise A.

    Annotations
    @inline()
  41. def toUndefOrNull: UndefOr[|[A, Null]]

    Uh-oh, thought it was A|Null but you need to say its a js.UndefOr[A|Null] because the docs were wrong :-).

    Uh-oh, thought it was A|Null but you need to say its a js.UndefOr[A|Null] because the docs were wrong :-).

    Annotations
    @inline()
  42. final def unzip[A1, A2](implicit asPair: <:<[A, (A1, A2)]): (|[A1, Null], |[A2, Null])
  43. def withFilter(p: (A) => Boolean): WithFilter[A]
    Annotations
    @inline()
  44. final def zip[A1 >: A, B](that: |[B, Null]): |[(A1, B), Null]

Inherited from AnyVal

Inherited from Any

Ungrouped