scala study

scala study的相关文章

Scala Study --- override

以前没使用过Scala, 其实我Java也是半截水平\无奈, 学Java的时候刚从C++中挣脱出来,发现Java无比优雅,但很快又对Java种种不信任程序员的设计感到受限. 直到, , 今天遇到了Scala\撒花 Scala的collection设计不能更赞!一段时间后打算专门写篇文章总结Scala,名字就叫"我为什么喜欢Scala!". 废话就不多说了,今天研究了一下Scala的override用法与特点. override --- one of the key words of S

Beginning Scala study note(8) Scala Type System

1. Unified Type System Scala has a unified type system, enclosed by the type Any at the top of the hierarchy and the type Nothing at the bottom of the hierarchy. All Scala types inherit from Any. # Using Any, Book extends AnyRef, and x is an Int that

Beginning Scala study note(9) Scala and Java Interoperability

1. Translating Java Classes to Scala Classes Example 1: # a class declaration in Java public class Book{} # Scala equivalent of a class declaration class Book Example 2: # a Java class with a Construtor public class Book{ private final int isbn; priv

Beginning Scala study note(6) Scala Collections

Scala's object-oriented collections support mutable and immutable type hierarchies. Also support functional higher-order operations such as map, filter, and reduce that let you use expression-oriented programming in collections. Higher-order operatio

Beginning Scala study note(5) Pattern Matching

The basic functional cornerstones of Scala: immutable data types, passing of functions as parameters and pattern matching. 1. Basic Pattern Matching In Scala, your cases can include types, wildcards, sequences, regular expressions, and so forth. scal

Beginning Scala study note(7) Trait

A trait provides code reusability in Scala by encapsulating method and state and then offing possibility of mixing them into classes thus allowing code reuse. #define Trait Gliding scala> trait Gliding{ | def gliding(){ println("gliding")} |

Beginning Scala study note(4) Functional Programming in Scala

1. Functional programming treats computation as the evaluation of mathematical and avoids state and mutable data. Scala encourages an expression-oriented programming(EOP) 1) In expression-oriented programming every statement is an expression. A state

Beginning Scala study note(2) Basics of Scala

1. Variables (1) Three ways to define variables: 1) val refers to define an immutable variable; scala> val x = 10 x: Int = 10 scala> x*x res4: Int = 100 scala> res4 + 1 # use result as a value res6: Int = 101 scala> res4 + res6 res7: Int = 201

Beginning Scala study note(3) Object Orientation in Scala

1. The three principles of OOP are encapsulation(封装性), inheritance(继承性) and polymorphism(多态性). example: class Shape{ def area: Double = 0.0 } # supertype # subtypes class Rectangle(val width: Double, val height: Double) extends Shape{ override def ar