Introduction


  • Multi-paradigm (多范式)
  • Concise, elegant, type-safe
  • Object-oriented and functional languages

Object-oriented

  • every value is an object
  • classes and traits
  • Mixin-based composition for a clean multiple inheritance

Functional

  • higher-order functions (高阶函数)
  • nested (嵌套函数,函数里面依然可以定义函数)
  • currying (柯里化)
  • case classes (类似java bean)
  • pattern matching
  • Singleton objects (用Object 实现singleton)
  • extractor objects (有uninply的函数,返回实例的参数)
  • for comprehensions (用yield实现 返回一个foreach)

statically typed

  • generic classes (泛型类)
  • variance annotations (型变, 协变和逆变,java中不支持这个)
  • upper and lower type bounds (类型的上边界 和下边界,跟java中一样)
  • inner classes(跟java中略有不同, 不对对象中的类 类型不一样,如果想一样采用不同写法)
  • abstract types (抽象类型,这个很好用,java中不存在这个)
  • compound types(复合类型,相当于指定同时又多个父类的子类)
  • implicit parameters and conversions (隐式参数,隐式表达式)
  • polymorphic methods (利用泛型,实现多态方法)