scala
文章平均质量分 64
cykic
在哪都是搬砖
展开
-
scala总结(4) -- 隐式转换以及隐式参数
隐式转换: implicit def intToString(i:Int) = i.toString implicit def可以对一种类型的参数自动做转换,在上面的隐式转换作用域中,所有Int 如果不符合编译要求,会先被转换为String 不可有多个隐式转换,如再加一个implicit def intToString2(i:Int) = i.toString + “2” 则编译报错原创 2015-01-21 11:25:07 · 513 阅读 · 0 评论 -
scala总结(1) -- trait, object, class等相关概念
trait: Serve as interfaces in Scala, can only have def inside, not val trait implements: class A extends B with C1 with C2... Functions can also be defined as trait or object like原创 2014-12-03 14:10:22 · 839 阅读 · 0 评论 -
scala总结(2)-- 集合类型
pattern matching 生成list 或是vector等的技巧: case class: a class that can use cases pattern e match { case p1 => exp1 case p2 => exp2 ... } a match exception will be thrown if no match w原创 2015-01-21 11:20:21 · 551 阅读 · 0 评论 -
scala总结(3)-- scala中常用类型继承关系
上图: in Scala Nothing will be used for all null like use cases Option: either Some or None 典型应用: Map中get方法返回Option: scores.get(“Alice”) match { case Some(score) => println(“sco原创 2015-01-21 11:23:23 · 653 阅读 · 0 评论 -
scala进阶:Future的理解及使用
看了下scala future的官方文档,融合了自己的理解整理在这里,例子全部来自官方文档:http://docs.scala-lang.org/overviews/core/futures.html future represents a result of an async method, would could due to long time-consuming operat原创 2015-06-20 16:11:54 · 11949 阅读 · 2 评论