Scala for the Impatient
学习一种新的语言,需要学习下面的问题:
- 程序的大致风格(过程语言,面向对象,函数语言,编译性,解释性)
- Various ways to run Scala code | ajduke's blog
- Scala REPL
- Scala to run scala script
- Scale to run Scala script with object and main method
- Run by Java
- 程序的整体结构(简单的),编译,与运行(典型的hello world)
- 应该可以分两种
- 最简单的程序可以是执行脚本,不需要定义类
- 复杂的程序则需要定义Object XXX以及main方法,和Java一致
- Scala程序最终可以编译成Java ByteCode并在JVM下执行
- 类型,常量,与变量的定义,表达式
- val定义常量
- var定义变量
- 强类型系统,但可以不指定类型,由系统猜得
- 见Page7,1.2/1.3
- Byte
- Char
- Short
- Int
- Long
- Float
- Double
- String
- toString()
- to()
- RichXXX
- 表达式
- P7 1.4
- a + b vs. a.+(b)
- 1.to(10) vs 1 to 10
- no ++/-- but +=1/-=1
- 为什么没有++/--
- 因为Int is immutable,所以其值不可变,这样就没法实现++/--了
- calling functions and methods
- p10 1.5
- import
- import math._
- _相当于Java中的*
- import math._ 相当于 import scala.math_
- static method vs. singleton objects
- Scala没有static method,但有一种叫singleton objects的东西
- Scala methods without parameters often don't use parentheses.
- .apply() method
- 流程
- An if expression has a value
- A block has a value - the value of its last expression
- The Scala for loop like an "enhanced" Java for loop
- Semicolons are (mostly) optional
- The void type is Unit
- Avoid using return in a function
- Beware of missing = in a function definition
- Exceptions work just like in Java or C++, but you use a "pattern matching" syntax for catch.
- Scala has no checked exceptions.
- 函数/对象定义与使用
- 数组,以及其他标准数据结构(list, set, map)
- 哪里获得在线帮助?
- p12 1.7 scaladoc
- http://www.scala-lang.org/api
- 类库与大系统make
1.1. The Scala Interpreter
1.2. Declaring Variables
1.3. Commonly Used Types
1.4. Arithmetic and Operator Overloading
1.6. The apply Method
1.7.Scaladoc
1.8. Exercises
2. Control Structures and Functions (A1)
2.1. Conditional Expressions
2.2. Statement Termination
2.3. Block Expressions and Assignments
2.4. Loops
2.6. _unctions
2.7. Derault and Yamed Arguments (L1)
2.8. Variable Arguments (L1)
2.9. Procedures
2.10. Lazy Values (L1)
2.11. Exceptions
2.12. Exercises
3. Arrays (A1)
3.1. _ixed Size Arrays
3.2. Variable Size Arrays: Array Burrers
3.3. Traversing Arrays (and Array Burrers)
3.4. Transrorming Arrays
3.6. Deciphering ScalaDoc
3.7. Multi-Dimensional Arrays
3.8. Interoperating with _ava
3.9. Exercises
4. Maps and Tuples (A1)
4.1. Constructing a Map
4.2. Accessing Map Values
4.3. Updating Map Values
4.4. Iterating Over Maps
4.6. Interoperating with _ava
4.7. Tuples
4.8. Zipping
4.9. Exercises
5. Classes (A1)
_.1. Simple Classes and Parameter-Less Methods
_.2. Properties with Getters and Setters
_.3. Properties with Only Getters
_.4. ObJect-Private _ields
_.6. Auxiliary Constructors
_.7. The Primary Constructor
_.8. Yested Classes (L1)
_.9. Exercises
6. Objects (A1)
6.1. Singletons6.2. Companion ObJects6.3. ObJects Extending a Class or Trait
6.4. The apply Method
6.6. Enumerations
6.7. Exercises
7. Packages and Imports (A1)
7.1.Packages
7.2. Scope Rules
7.3. Chained Package Clauses
7.4. Top-or-_ile Yotation
7.6. Package Visibility
7.7. Imports
7.8. Imports Can Be Anywhere
7.9. Renaming and Hiding Members
7.10.ImplicitImports
7.11. Exercises
8. Inheritance(A1)
8.1. Extending a Class
8.2. Overriding Methods
8.3. Type Checks and Casts
8.4. Protected _ields and Methods
8.6. Overriding _ields
8.7. Anonymous Subclasses
8.8. Abstract Classes
8.9. Abstract _ields
8.10. Construction Order and Early Der_nitions (L3)
8.11. The Scala Inheritance Hierarchy
8.12. ObJect Equality (L1)
8.13. Exercises
9. Files and Regular Expressions (A1)
9.1. Reading Lines9.2. Reading Characters
9.3. Reading Tokens and Yumbers
9.4. Reading rrom URLs and Other Sources
9.6. Writing Text _iles
9.7. Visiting Directories
9.8.Serialization
9.9. Regular Expressions
9.10.Regular Expression Groups
9.11. Exercises
No comments:
Post a Comment