final class OneOfTwo[+A, +B] extends AnyVal with Any.Able.ToString

Represents value of one of two possible types (a disjoint union)

OneOfTwo is NOT biased. Two and One values are logically equal

Implementation wise Two takes a little bit more resources, so putting more frequent types one is justified

var o: OneOfTwo[String, Int] = "foo"

o.lp        // Prints: One(foo)

o = 777

o.lp        // Prints: Two(777)

o = "bar"

o.lp        // Prints: One(bar)
Ordering
  1. Alphabetic
Inherited
  1. OneOfTwo
  2. Any.Able.ToString
  3. scala.AnyVal
  4. scala.Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Method

  1. def any: Any

    Any value

    Any value

    Returns OneOfTwo value, whatever it is: one or two

    Definition Classes
    OneOfTwo
  2. def apply(one: (A) ⇒ Any, two: (B) ⇒ Any): Unit

    Process OneOfTwo, either: one or two

    Process OneOfTwo, either: one or two

    Takes two functions, one to process one value, another - two value

    Definition Classes
    OneOfTwo
  3. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  4. def convert[C](f1: (A) ⇒ C, f2: (B) ⇒ C): C

    Convert OneOfTwo

    Convert OneOfTwo

    Takes two functions, one to convert one value, another - two value

    Definition Classes
    OneOfTwo
  5. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  6. def isOne: Boolean

    One test

    One test

    Returns true if this OneOfTwo holds one value

    Definition Classes
    OneOfTwo
  7. def isTwo: Boolean

    Two test

    Two test

    Returns true if this OneOfTwo holds two value

    Definition Classes
    OneOfTwo
  8. def mapOne[C](f: (A) ⇒ C): OneOfTwo[C, B]

    Map one

    Map one

    Maps one value or returns OneOfTwo as is, if it is two

    Definition Classes
    OneOfTwo
  9. def mapTwo[C](f: (B) ⇒ C): OneOfTwo[A, C]

    Map one

    Map one

    Maps two value or returns OneOfTwo as is, if it is one

    Definition Classes
    OneOfTwo
  10. def one: A
    Definition Classes
    OneOfTwo
  11. def oneOpt: Opt[A]

    One value

    One value

    Optionally returns one value

    Definition Classes
    OneOfTwo
  12. def toString: String

    Custom String description

    Custom String description

    Overrides default toString method with custom description

    Definition Classes
    OneOfTwoToString → Any
  13. def two: Opt[B]
    Definition Classes
    OneOfTwo
  14. def twoOpt: Opt[B]

    Two value

    Two value

    Optionally returns two value

    Definition Classes
    OneOfTwo

Operator

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
Linear Supertypes
Any.Able.ToString, AnyVal, Any
Source: OneOfTwo.scala