译者序............................................III序...............................XV前言............................................XVII作者简介......................................XIX第1章 基础A1 .............................11.1 Scala解释器 .....................................11.2 声明值和变量.................................31.3 常用类型.........................................41.4 算术和操作符重载.............................................51.5 调用函数和方法..............................71.6 apply方法 ........................................81.7 Scaladoc...........................................9练习.....................................11第2章 控制结构和函数A1 ............................132.1 条件表达式..................................142.2 语句终止.......................................162.3 块表达式和赋值...............................................162.4 输入和输出 ..................................172.5 循环...............................................182.6 高级for循环和for推导式..................................192.7 函数...............................................212.8 默认参数和带名参数 L1..............................222.9 变长参数L1...............................222.10 过程...............................................232.11 懒值L1.......................................242.12 异常...............................................25练习.....................................27第3章 数组相关操作A1 ................................293.1 定长数组.......................................293.2 变长数组:数组缓冲.......................................303.3 遍历数组和数组缓冲.......................................313.4 数组转换.......................................323.5 常用算法.......................................343.6 解读Scaladoc.................................353.7 多维数组.......................................373.8 与Java的互操作 ................................................37练习.....................................38第4章 映射和元组A1 ...................................414.1 构造映射.......................................414.2 获取映射中的值...............................................424.3 更新映射中的值...............................................434.4 迭代映射.......................................444.5 已排序映射...................................444.6 与Java的互操作 ................................................454.7 元组...............................................454.8 拉链操作.......................................46练习.....................................47第5章 类A1 ...............................515.1 简单类和无参方法...........................................515.2 带getter和setter的属性......................................525.3 只带getter的属性 ..............................................555.4 对象私有字段................................565.5 Bean属性L1................................575.6 辅助构造器...................................595.7 主构造器.......................................605.8 嵌套类L1...................................63练习.....................................65第6章 对象A1 ...........................696.1 单例对象.......................................696.2 伴生对象.......................................706.3 扩展类或特质的对象.......................................716.4 apply方法 ......................................726.5 应用程序对象................................736.6 枚举...............................................74练习.....................................75第7章 包和引入A1 .......................................797.1 包...................................................807.2 作用域规则...................................817.3 串联式包语句................................837.4 文件顶部标记法...............................................837.5 包对象...........................................847.6 包可见性.......................................857.7 引入...............................................857.8 任何地方都可以声明引入 ..............................867.9 重命名和隐藏方法...........................................877.10 隐式引入.......................................87练习.....................................88第8章 继承A1 ..........................918.1 扩展类...........................................918.2 重写方法.......................................928.3 类型检查和转换...............................................938.4 受保护字段和方法...........................................948.5 超类的构造...................................948.6 重写字段.......................................958.7 匿名子类.......................................968.8 抽象类...........................................978.9 抽象字段.......................................978.10 构造顺序和提前定义L3...............................988.11 Scala继承层级..............................1008.12 对象相等性L1.............................................101练习......................................................102第9章 文件和正则表达式A1 .......................1059.1 读取行.........................................1069.2 读取字符.....................................1069.3 读取词法单元和数字.....................................1079.4 从URL或其他源读取 .....................................1089.5 读取二进制文件.............................................1089.6 写入文本文件..............................1089.7 访问目录.....................................1099.8 序列化.........................................1109.9 进程控制A2 ..............................1119.10 正则表达式.................................1139.11 正则表达式组..............................114练习......................................................114第10章 特质L1 ..........................................11710.1 为什么没有多重继承...................................11710.2 当做接口使用的特质...................................11910.3 带有具体实现的特质...................................12010.4 带有特质的对象...........................................12110.5 叠加在一起的特质.......................................12210.6 在特质中重写抽象方法...............................12410.7 当做富接口使用的特质...............................12410.8 特质中的具体字段.......................................12510.9 特质中的抽象字段.......................................12610.10 特质构造顺序...............................................12710.11 初始化特质中的字段...................................12910.12 扩展类的特质...............................................13110.13 自身类型L2...............................................13210.14 背后发生了什么...........................................133练习......................................................135第11章 操作符L1 .......................................13911.1 标识符.......................................13911.2 中置操作符................................14011.3 一元操作符................................14111.4 赋值操作符................................14211.5 优先级.......................................14211.6 结合性.......................................14311.7 apply和update方法........................................14411.8 提取器L2................................14511.9 带单个参数或无参数的提取器L2..............................14611.10 unapplySeq方法L2....................................147练习......................................................148第12章 高阶函数L1 ...................................15112.1 作为值的函数...............................................15112.2 匿名函数...................................15212.3 带函数参数的函数.......................................15312.4 参数(类型)推断.......................................15412.5 一些有用的高阶函数...................................15512.6 闭包...........................................15612.7 SAM转换...................................15712.8 柯里化.......................................15812.9 控制抽象...................................15912.10 return表达式...............................161练习......................................................162第13章 集合A2 ..........................................16513.1 主要的集合特质...........................................16613.2 可变和不可变集合.......................................16713.3 序列...........................................16813.4 列表...........................................16913.5 可变列表...................................17013.6 集...............................................17113.7 用于添加或去除元素的操作符......................................17313.8 常用方法...................................17513.9 将函数映射到集合 .......................................17713.10 化简、折叠和扫描A3...............................17813.11 拉链操作...................................18113.12 迭代器.......................................18313.13 流A3.......................................18413.14 懒视图.......................................18513.15 与Java集合的互操作 ....................................18613.16 线程安全的集合...........................................18813.17 并行集合...................................188练习......................................................190第14章 模式匹配和样例类A2 .....................19314.1 更好的switch..............................19414.2 守卫...........................................19514.3 模式中的变量...............................................19514.4 类型模式...................................19614.5 匹配数组、列表和元组...............................19714.6 提取器.......................................19814.7 变量声明中的模式.......................................19914.8 for表达式中的模式 .......................................19914.9 样例类.......................................20014.10 copy方法和带名参数....................................20114.11 case语句中的中置表示法.............................20114.12 匹配嵌套结构...............................................20214.13 样例类是邪恶的吗.......................................20314.14 密封类.......................................20414.15 模拟枚举...................................20514.16 Option类型................................20514.17 偏函数L2................................207练习......................................................207第15章 注解A2 ..........................................21115.1 什么是注解................................21215.2 什么可以被注解...........................................21215.3 注解参数...................................21315.4 注解实现...................................21415.5 针对Java特性的注解 ....................................21615.5.1 Java修饰符 ......................................21615.5.2 标记接口.........................................21615.5.3 受检异常.........................................21715.5.4 变长参数.........................................21715.5.5 JavaBeans........................................21815.6 用于优化的注解...........................................21915.6.1 尾递归.............................................21915.6.2 跳转表生成与内联.........................22015.6.3 可省略方法.....................................22115.6.4 基本类型的特殊化.........................22215.7 用于错误和警告的注解...............................223练习......................................................224第16章 XML处理