# 隱式參數

``implicit val default = 1   // 也可以寫為 implicit def default = 1def increase(a: Int)(implicit b: Int) = a + bprintln(increase(10)(20))         // 30println(increase(10)(default))    // 11``

println(increase(10)(default))

``implicit val default = "openhome.cc > "def command(implicit prompt: String) = readLine(prompt)val c = commandprintln(c)``

``implicit val p = "number > "implicit val v = 1def increase(implicit prompt: String, i: Int) = readLine(prompt).toInt + iprintln(increase)   // 相當於 println(increase(p, v))``

``def quick(list: List[Int]): List[Int] = {    list match {        case Nil => Nil             case x::xs =>                val (before,after) = xs partition (_ < x)        quick(before) ++ (x :: quick(after))    }}``

``def quick[T <: Ordered[T]](list: List[T]): List[T] = {    list match {        case Nil => Nil             case x::xs =>                val (before,after) = xs partition (_ < x)        quick(before) ++ (x :: quick(after))    }}``

``def quick[T](list: List[T])(implicit orderer: T => Ordered[T]): List[T] = {    list match {        case Nil => Nil             case x::xs =>                val (before,after) = xs partition (orderer(_) < x)        quick(before) ++ (x :: quick(after))    }}``

implicit def identity[A](x: A): A = x

``def quick[T](list: List[T])(implicit orderer: T => Ordered[T]): List[T] = {    list match {        case Nil => Nil             case x::xs =>                val (before,after) = xs partition (_ < x) // orderer(_) 是隱含的        quick(before) ++ (x :: quick(after))    }}``

``def quick[T <% Ordered[T]](list: List[T]): List[T] = {    list match {        case Nil => Nil             case x::xs =>                val (before,after) = xs partition (_ < x)        quick(before) ++ (x :: quick(after))    }}``