scala.scalajs.js

UndefOr

sealed trait UndefOr[+A] extends AnyRef

Value of type A or the JS undefined value.

js.UndefOr[A] is the type of a value that can be either undefined or an A. It provides an API similar to that of scala.Option through the UndefOrOps implicit class, where undefined take the role of None.

By extension, this type is also suited to typing optional fields in native JS types, i.e., fields that may not exist on the object.

Annotations
@RawJSType()
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. UndefOr
  2. AnyRef
  3. Any
Implicitly
  1. by undefOr2ops
  2. by any2undefOrA
  3. by undefOr2jsAny
  4. by any2undefOrUnion
  5. by any2stringadd
  6. by any2stringfmt
  7. by any2ArrowAssoc
  8. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: scala.Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (UndefOr[A], B)

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to ArrowAssoc[UndefOr[A]] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: scala.Any): Boolean

    Definition Classes
    Any
  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. final def collect[B](pf: PartialFunction[A, B]): UndefOr[B]

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

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

    pf

    the partial function.

    returns

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

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  11. final def contains[A1 >: A](elem: A1): Boolean

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

    Tests whether the 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 UndefOr has an element that is equal (as determined by ==) to elem, false otherwise.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  12. def ensuring(cond: (UndefOr[A]) ⇒ Boolean, msg: ⇒ scala.Any): UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to Ensuring[UndefOr[A]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: (UndefOr[A]) ⇒ Boolean): UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to Ensuring[UndefOr[A]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean, msg: ⇒ scala.Any): UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to Ensuring[UndefOr[A]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean): UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to Ensuring[UndefOr[A]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def equals(arg0: scala.Any): Boolean

    Definition Classes
    AnyRef → Any
  18. final def exists(p: (A) ⇒ Boolean): Boolean

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

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

    p

    the predicate to test

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  19. final def filter(p: (A) ⇒ Boolean): UndefOr[A]

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

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

    p

    the predicate used for testing.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  20. final def filterNot(p: (A) ⇒ Boolean): UndefOr[A]

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

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

    p

    the predicate used for testing.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  21. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. final def flatMap[B](f: (A) ⇒ UndefOr[B]): UndefOr[B]

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

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

    f

    the function to apply

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    foreach

    map

  23. def flatten[B](implicit ev: <:<[A, UndefOr[B]]): UndefOr[B]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
  24. final def fold[B](ifEmpty: ⇒ B)(f: (A) ⇒ B): B

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

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

    ifEmpty

    the expression to evaluate if empty.

    f

    the function to apply if nonempty.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Note

    This is equivalent to UndefOr map f getOrElse ifEmpty.

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

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

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

    p

    the predicate to test

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  26. 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 information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    flatMap

    map

  27. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  28. final def get: A

    Returns the option's value.

    Returns the option's value.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Exceptions thrown
    java.util.NoSuchElementException

    if the option is empty.

    Note

    The option must be nonEmpty.

  29. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  30. 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 information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  31. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  32. 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 information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  33. final def isEmpty: Boolean

    Returns true if the option is undefined, false otherwise.

    Returns true if the option is undefined, false otherwise.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  34. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  35. def iterator: collection.Iterator[A]

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

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

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
  36. final def map[B](f: (A) ⇒ B): UndefOr[B]

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

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

    f

    the function to apply

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Note

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

    See also

    foreach

    flatMap

  37. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  38. final def nonEmpty: Boolean

    Returns false if the option is undefined, true otherwise.

    Returns false if the option is undefined, true otherwise.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Note

    Implemented here to avoid the implicit conversion to Iterable.

  39. final def notify(): Unit

    Definition Classes
    AnyRef
  40. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  41. final def orElse[B >: A](alternative: ⇒ UndefOr[B]): UndefOr[B]

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

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

    alternative

    the alternative expression.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  42. 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 UndefOr must often interface with code that expects and returns nulls.

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    Example:
    1. val initalText: Option[String] = getInitialText
      val textField = new JComponent(initalText.orNull,20)
  43. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  44. 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 UndefOr's value if this UndefOr is nonempty.

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

    right

    the expression to evaluate and return if this is empty

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    toRight

  45. def toList: List[A]

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

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

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
  46. final def toOption: Option[A]

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

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

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  47. final def toRight[X](left: ⇒ X): Either[X, A]

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

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

    left

    the expression to evaluate and return if this is empty

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
    See also

    toLeft

  48. def toString(): String

    Definition Classes
    AnyRef → Any
  49. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def withFilter(p: (A) ⇒ Boolean): WithFilter[A]

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

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

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Definition Classes
    UndefOrOps
    Annotations
    @inline()
  53. def [B](y: B): (UndefOr[A], B)

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to ArrowAssoc[UndefOr[A]] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to UndefOrOps[A] performed by method undefOr2ops in scala.scalajs.js.UndefOr.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (undefOr: UndefOrOps[A]).self
    Definition Classes
    UndefOrOps
  2. val self: scala.Any

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (undefOr: StringAdd).self
    Definition Classes
    StringAdd
  3. val self: scala.Any

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (undefOr: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to ArrowAssoc[UndefOr[A]] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (undefOr: ArrowAssoc[UndefOr[A]]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: UndefOr[A]

    Implicit information
    This member is added by an implicit conversion from UndefOr[A] to Ensuring[UndefOr[A]] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (undefOr: Ensuring[UndefOr[A]]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from AnyRef

Inherited from scala.Any

Inherited by implicit conversion undefOr2ops from UndefOr[A] to UndefOrOps[A]

Inherited by implicit conversion any2undefOrA from UndefOr[A] to UndefOr[UndefOr[A]]

Inherited by implicit conversion undefOr2jsAny from UndefOr[A] to Any

Inherited by implicit conversion any2undefOrUnion from UndefOr[A] to UndefOr[|[B1, B2]]

Inherited by implicit conversion any2stringadd from UndefOr[A] to StringAdd

Inherited by implicit conversion any2stringfmt from UndefOr[A] to StringFormat

Inherited by implicit conversion any2ArrowAssoc from UndefOr[A] to ArrowAssoc[UndefOr[A]]

Inherited by implicit conversion any2Ensuring from UndefOr[A] to Ensuring[UndefOr[A]]

Ungrouped