[+T], [-T]
)<:, >:, >:>
)case class A(val x: Int, val y: String) {
def f = x.toString + y
}
class A[T, +U <: T, -C]() extends B[T]
def f(a: Any) = a match {
case x: Int => "Integer"
case (_, sec @ (_, "tupling")) => "Comlex tuple" + sec.toString
case _ => "default"
}
val pat = "[a-z]".r
"asdf" match {
case pat => "Matched!"
case _ => "No match"
}
object apply
, flatMap
Option[A]
Future[A]
, Promise[A]
Try[A]
, Success[A]
, Failure[A]
Either[A]
.
, ()
, ;
, {}
)$
-t kivéve bármi lehet függvénynév (pl. +=:
)def f(x: String)(f: Unit => Unit) = [...]
f("DoSomething") {
[...]
}
reify
, splice
def hello(param: String): Unit = macro hello_impl
def hello_impl(c: Context)(param: c.Expr[String]): c.Expr[Unit] ={
import c.universe._
reify { println("Hello " + param.splice + "!") }
}
hello("World") ~> println("Hello " + "World" + "!")
class A(x: Int){object B {val z = x * 2}}
val a1 = A(1); val a2 = A(1)
a1.B =:= a2.B
hamismap
, zip
, flatMap
, fold
, fold[Left, Right]
, groupBy
, find
...
actor ! msg
val myXML = <input type='radio'
name={package.getMeTheName()}
value='true'
checked={ if (myFunc.get.isEmpty) {
"checked"
} else {
null
}}/>