文章分类 - programming
摘要:# `msort` vs `sortWith`~~~scalaval ls = List("a", "b", "c", "d", "e")msort((x: Char, y: Char) => x > y)(ls)ls sortWith(_ > _)msort(_ > _)(ls) // er...
阅读全文
摘要:# Case Class and Pattern Matching## A simple example~~~scalaabstract class Exprcase class Var(name: String) extends Exprcase class Number(name: Double...
阅读全文
摘要:# TraitsTraits are a fundamental unit of code reuse in Scala. A trait encapsulates method and field definitions, which can then be reused by mixing th...
阅读全文
摘要:## 特殊之处In Scala assignment always results in the unit value, ()```scalavar a = 1(a = 2).getClass //=> Class[Unit] = void```## 读取文件```scalaimport s...
阅读全文
摘要:## Composition and Inheritance1. abstract classes2. parameterless methods3. extending classes4. overriding methods and fields5. parametric fields6. in...
阅读全文
摘要:# 4.1 Computational EffectsThe *value* produced by a computation may have *effects* as well: it may read,print,or alter the state of memory or a file ...
阅读全文
浙公网安备 33010602011771号