key points in scala-for-impatient 2nd book, best book for java developer to use scala in a rush.
scala-for-impatient 章节摘要,这本书对于 Java 开发者快速上手 Scala 帮助很大。
some notes on scala future, includes:
[…] import java.time._ import scala.concurrent._ import ExecutionContext.Implicits.global Future { Thread.sleep(10000) println(s"This is the future at …
Scala 中很多使用 if 的地方都可以用 match case 来替换。常见的就是下面的这种写法:
[…] val res = msg match { case it if it.contains("H") => "Hello" case _ => "Other" } //更常见的用法是去匹配参数的模式: case …
scala type class notes:
关于 scala type class 非常好的文章
[…] //scala 没有专门的 type class 语法,而是借助 trait + implicit + context bound 来实现的, //所以很多时候识别 type class 比较困难。 //type class 由三部分构成 //1. type class: 即 …
//隐式参数是在调用时可以自动填充的参数,需要在调用范围内(scope) 有一个隐式变量可供填充。 def addInt(i:Int)(implicit n: Int) = i + n //需要提供一个隐式变量 n implicit val sn = 1 addInt(2) // 3 //如果有两个满足类型的隐式变量,则在编译 addInt(2) 时报错 //scala …