scala

PartialFunction

object PartialFunction extends AnyRef

A few handy operations which leverage the extra bit of information available in partial functions. Examples:

 import PartialFunction._

def strangeConditional(other: Any): Boolean = cond(other) { case x: String if x == "abc" || x == "def" => true case x: Int => true } def onlyInt(v: Any): Option[Int] = condOpt(v) { case x: Int => x }

go to: companion
source: PartialFunction.scala
    since
  1. 2.8

    authors:
  1. Paul Phillips

Inherited
  1. Hide All
  2. Show all
  1. AnyRef
  2. Any
Visibility
  1. Public
  2. All

Value Members

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

  2. def !=(arg0: Any): Boolean

    o != arg0 is the same as !(o == (arg0)).

  3. def ##(): Int

  4. def $asInstanceOf[T0](): T0

  5. def $isInstanceOf[T0](): Boolean

  6. def ==(arg0: AnyRef): Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

  7. def ==(arg0: Any): Boolean

    o == arg0 is the same as o.equals(arg0).

  8. def asInstanceOf[T0]: T0

    This method is used to cast the receiver object to be of type T0.

  9. def clone(): AnyRef

    This method creates and returns a copy of the receiver object.

  10. def cond[T](x: T)(pf: PartialFunction[T, Boolean]): Boolean

    Creates a Boolean test based on a value and a partial function.

  11. def condOpt[T, U](x: T)(pf: PartialFunction[T, U]): Option[U]

    Transforms a PartialFunction[T, U] pf' into Function1[T, Option[U]] f' whose result is Some(x) if the argument is in pf's domain and None otherwise, and applies it to the value x'. In effect, it is a 'match' statement which wraps all case results in Some(_) and adds 'case _ => None' to the end.

  12. def eq(arg0: AnyRef): Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

  13. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

  14. def finalize(): Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

  15. def getClass(): java.lang.Class[_ <: java.lang.Object]

    Returns a representation that corresponds to the dynamic class of the receiver object.

  16. def hashCode(): Int

    Returns a hash code value for the object.

  17. def isInstanceOf[T0]: Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

  18. def ne(arg0: AnyRef): Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

  19. def notify(): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

  20. def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

  21. def synchronized[T0](arg0: T0): T0

  22. def toString(): String

    Returns a string representation of the object.

  23. def wait(): Unit

  24. def wait(arg0: Long, arg1: Int): Unit

  25. def wait(arg0: Long): Unit