trait PatternMatchers

trait PatternMatchers

 extends ScalaObject

The PatternMatchers trait provides matchers which allow to use pattern matching to match expressions.

Companion: PatternMatchers

Source: PatternMatchers.scala(8)

Direct Known Subclasses

Matchers, PatternMatchers,

Nested Classes



beSomething def beSomething
Alias for beSome[Any]


!= final def !=(arg0 : Object) Boolean AnyRef
!= final def !=(arg0 : Any) Boolean Any
== final def ==(arg0 : Any) Boolean Any
== final def ==(arg0 : Object) Boolean AnyRef
asInstanceOf final def asInstanceOf[T0] T0 Any
beAlsoNone def beAlsoNone[T](a : => Option[T])
- use beAsNoneAs
beAsNoneAs def beAsNoneAs[T](a : => Option[T])
Matches if a is None when v is None and a is not None when v is not None
beLike def beLike(pattern : => (Any) => Boolean)
Matches if the value v is like the pattern { case expression => boolean }

It uses the fact that we can use the following syntax to map Options:

  • myOption [details]
    map { case expression => boolean }

In that case, the pattern parameter would be { case expression => boolean }, a function of type Any => Boolean

The Sugar object can be used to get a shorter expression by having the ok alias for true:

  • List(1, 2) must beLike { case x::y::Nil => ok }
pattern - a case expression
- false if there is no match
- the value inside the mapped option if there is a match, which should be true
beNone def beNone[T]
Matches if the value v is None
beSome def beSome[T]
Matches if the value v is Some(x)
clone protected def clone Object AnyRef
eq final def eq(arg0 : Object) Boolean AnyRef
equals def equals(arg0 : Any) Boolean AnyRef
finalize protected def finalize Unit AnyRef
getClass final def getClass Class[Object] AnyRef
hashCode def hashCode Int AnyRef
isInstanceOf final def isInstanceOf[T0] Boolean Any
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
toString def toString String AnyRef
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait final def wait Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
Copyright (c) 2007-2009. All Rights Reserved.