Packages

sealed trait |[A, B] extends AnyRef

Value of type A or B (union type).

Scala does not have union types, but they are important to many interoperability scenarios. This type provides a (partial) encoding of union types using implicit evidences.

Annotations
@JSType()
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. |
  2. AnyRef
  3. Any
Implicitly
  1. by undefOr2ops
  2. by undefOr2jsAny
  3. by UnionOps
  4. by any2stringadd
  5. by StringFormat
  6. by Ensuring
  7. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: scala.Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from |[A, B] to any2stringadd[|[A, B]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (|[A, B], B)
    Implicit
    This member is added by an implicit conversion from |[A, B] to ArrowAssoc[|[A, B]] performed by method ArrowAssoc in scala.Predef. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: scala.Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. final def collect[B](pf: PartialFunction[A, B]): UndefOr[B]

    Returns the result of applying pf to this js.UndefOr's contained value, if this option is nonempty and pf is defined for that value.

    Returns the result of applying pf to this js.UndefOr's contained value, if this option is nonempty and pf is defined for that value. Returns js.undefined otherwise.

    pf

    the partial function.

    returns

    the result of applying pf to this js.UndefOr's value (if possible), or js.undefined.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  9. final def contains[A1 >: A](elem: A1): Boolean

    Tests whether the js.UndefOr contains a given value as an element.

    Tests whether the js.UndefOr contains a given value as an element.

    x.contains(y) differs from x == y only in the fact that it will return false when x and y are both undefined.

    elem

    the element to test.

    returns

    true if the js.UndefOr has an element that is equal (as determined by ==) to elem, false otherwise.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  10. def ensuring(cond: (|[A, B]) ⇒ Boolean, msg: ⇒ scala.Any): |[A, B]
    Implicit
    This member is added by an implicit conversion from |[A, B] to Ensuring[|[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: (|[A, B]) ⇒ Boolean): |[A, B]
    Implicit
    This member is added by an implicit conversion from |[A, B] to Ensuring[|[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean, msg: ⇒ scala.Any): |[A, B]
    Implicit
    This member is added by an implicit conversion from |[A, B] to Ensuring[|[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean): |[A, B]
    Implicit
    This member is added by an implicit conversion from |[A, B] to Ensuring[|[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: scala.Any): Boolean
    Definition Classes
    AnyRef → Any
  16. final def exists(p: (A) ⇒ Boolean): Boolean

    Returns true if this option is nonempty and the predicate p returns true when applied to this js.UndefOr's value.

    Returns true if this option is nonempty and the predicate p returns true when applied to this js.UndefOr's value. Otherwise, returns false.

    p

    the predicate to test

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  17. final def filter(p: (A) ⇒ Boolean): UndefOr[A]

    Returns this js.UndefOr if it is nonempty and applying the predicate p to this js.UndefOr's value returns true.

    Returns this js.UndefOr if it is nonempty and applying the predicate p to this js.UndefOr's value returns true. Otherwise, return js.undefined.

    p

    the predicate used for testing.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  18. final def filterNot(p: (A) ⇒ Boolean): UndefOr[A]

    Returns this js.UndefOr if it is nonempty and applying the predicate p to this js.UndefOr's value returns false.

    Returns this js.UndefOr if it is nonempty and applying the predicate p to this js.UndefOr's value returns false. Otherwise, return js.undefined.

    p

    the predicate used for testing.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  19. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. final def flatMap[B](f: (A) ⇒ UndefOr[B]): UndefOr[B]

    Returns the result of applying f to this js.UndefOr's value if this js.UndefOr is nonempty.

    Returns the result of applying f to this js.UndefOr's value if this js.UndefOr is nonempty. Returns js.undefined if this js.UndefOr is empty. Slightly different from map in that f is expected to return an js.UndefOr (which could be js.undefined).

    f

    the function to apply

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    map

    foreach

  21. def flatten[B](implicit ev: <:<[A, UndefOr[B]]): UndefOr[B]
    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
  22. final def fold[B](ifEmpty: ⇒ B)(f: (A) ⇒ B): B

    Returns the result of applying f to this js.UndefOr's value if the js.UndefOr is nonempty.

    Returns the result of applying f to this js.UndefOr's value if the js.UndefOr is nonempty. Otherwise, evaluates expression ifEmpty.

    ifEmpty

    the expression to evaluate if empty.

    f

    the function to apply if nonempty.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Note

    This is equivalent to js.UndefOr map f getOrElse ifEmpty.

  23. final def forall(p: (A) ⇒ Boolean): Boolean

    Returns true if this option is empty or the predicate p returns true when applied to this js.UndefOr's value.

    Returns true if this option is empty or the predicate p returns true when applied to this js.UndefOr's value.

    p

    the predicate to test

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  24. final def foreach[U](f: (A) ⇒ U): Unit

    Apply the given procedure f to the option's value, if it is nonempty.

    Apply the given procedure f to the option's value, if it is nonempty. Otherwise, do nothing.

    f

    the procedure to apply.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    map

    flatMap

  25. final def get: A

    Returns the option's value.

    Returns the option's value.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Exceptions thrown

    java.util.NoSuchElementException if the option is empty.

    Note

    The option must be nonEmpty.

  26. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  27. final def getOrElse[B >: A](default: ⇒ B): B

    Returns the option's value if the option is nonempty, otherwise return the result of evaluating default.

    Returns the option's value if the option is nonempty, otherwise return the result of evaluating default.

    default

    the default expression.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. final def isDefined: Boolean

    Returns true if the option is not undefined, false otherwise.

    Returns true if the option is not undefined, false otherwise.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  30. final def isEmpty: Boolean

    Returns true if the option is undefined, false otherwise.

    Returns true if the option is undefined, false otherwise.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. def iterator: collection.Iterator[A]

    Returns a singleton iterator returning the js.UndefOr's value if it is nonempty, or an empty iterator if the option is empty.

    Returns a singleton iterator returning the js.UndefOr's value if it is nonempty, or an empty iterator if the option is empty.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
  33. final def map[B](f: (A) ⇒ B): UndefOr[B]

    Returns the result of applying f to this js.UndefOr's value if this js.UndefOr is nonempty.

    Returns the result of applying f to this js.UndefOr's value if this js.UndefOr is nonempty. Otherwise return js.undefined.

    f

    the function to apply

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Note

    This is similar to flatMap except here, f does not need to wrap its result in an js.UndefOr.

    See also

    flatMap

    foreach

  34. def merge[B](implicit ev: Evidence[|[A, B], B]): B

    Explicitly merge a union type to a supertype (which might not be a union type itself).

    Explicitly merge a union type to a supertype (which might not be a union type itself).

    This needs evidence that A <: B.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UnionOps[|[A, B]] performed by method UnionOps in scala.scalajs.js.|.
    Definition Classes
    UnionOps
  35. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  36. final def nonEmpty: Boolean

    Returns false if the option is js.undefined, true otherwise.

    Returns false if the option is js.undefined, true otherwise.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Note

    Implemented here to avoid the implicit conversion to Iterable.

  37. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  38. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  39. final def orElse[B >: A](alternative: ⇒ UndefOr[B]): UndefOr[B]

    Returns this js.UndefOr if it is nonempty, otherwise return the result of evaluating alternative.

    Returns this js.UndefOr if it is nonempty, otherwise return the result of evaluating alternative.

    alternative

    the alternative expression.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  40. final def orNull[A1 >: A](implicit ev: <:<[Null, A1]): A1

    Returns the option's value if it is nonempty, or null if it is empty.

    Returns the option's value if it is nonempty, or null if it is empty. Although the use of null is discouraged, code written to use js.UndefOr must often interface with code that expects and returns nulls.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Example:
    1. val initalText: Option[String] = getInitialText
      val textField = new JComponent(initalText.orNull,20)
  41. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  42. final def toLeft[X](right: ⇒ X): Either[A, X]

    Returns a Right containing the given argument right if this is empty, or a Left containing this js.UndefOr's value if this js.UndefOr is nonempty.

    Returns a Right containing the given argument right if this is empty, or a Left containing this js.UndefOr's value if this js.UndefOr is nonempty.

    right

    the expression to evaluate and return if this is empty

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    toRight

  43. def toList: List[A]

    Returns a singleton list containing the js.UndefOr's value if it is nonempty, or the empty list if the js.UndefOr is empty.

    Returns a singleton list containing the js.UndefOr's value if it is nonempty, or the empty list if the js.UndefOr is empty.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
  44. final def toOption: Option[A]

    Returns a Some containing this js.UndefOr's value if this js.UndefOr is nonempty, None otherwise.

    Returns a Some containing this js.UndefOr's value if this js.UndefOr is nonempty, None otherwise.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  45. final def toRight[X](left: ⇒ X): Either[X, A]

    Returns a Left containing the given argument left if this js.UndefOr is empty, or a Right containing this js.UndefOr's value if this is nonempty.

    Returns a Left containing the given argument left if this js.UndefOr is empty, or a Right containing this js.UndefOr's value if this is nonempty.

    left

    the expression to evaluate and return if this is empty

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    toLeft

  46. def toString(): String
    Definition Classes
    AnyRef → Any
  47. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  50. final def withFilter(p: (A) ⇒ Boolean): WithFilter[A]

    Necessary to keep js.UndefOr from being implicitly converted to scala.collection.Iterable in for comprehensions.

    Necessary to keep js.UndefOr from being implicitly converted to scala.collection.Iterable in for comprehensions.

    Implicit
    This member is added by an implicit conversion from |[A, B] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.|. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  51. def [B](y: B): (|[A, B], B)
    Implicit
    This member is added by an implicit conversion from |[A, B] to ArrowAssoc[|[A, B]] performed by method ArrowAssoc in scala.Predef. This conversion will take place only if B is Unit (B =:= Unit).
    Definition Classes
    ArrowAssoc

Deprecated Value Members

  1. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from |[A, B] to StringFormat[|[A, B]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

Inherited from AnyRef

Inherited from scala.Any

Inherited by implicit conversion undefOr2ops from |[A, B] to UndefOrOps[A]

Inherited by implicit conversion undefOr2jsAny from |[A, B] to Any

Inherited by implicit conversion UnionOps from |[A, B] to UnionOps[|[A, B]]

Inherited by implicit conversion any2stringadd from |[A, B] to any2stringadd[|[A, B]]

Inherited by implicit conversion StringFormat from |[A, B] to StringFormat[|[A, B]]

Inherited by implicit conversion Ensuring from |[A, B] to Ensuring[|[A, B]]

Inherited by implicit conversion ArrowAssoc from |[A, B] to ArrowAssoc[|[A, B]]

Ungrouped