Server VM, Java 1.6.0_37). Type in expressions to have them evaluated. Type :help for more information. scala> 1 + 2 res0: Int = 3 scala> println("1 + 2 = " + res0) 1 + 2 = 3 scala> :quit
int age = 0; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public int getAge() { return this.age; } public void setAge(int age) { this.age = age; } } Java Person - name: String - age: int case Ϋϥε
object Engine extends CarElement case object Body extends CarElement case class Car(elements: List[CarElement]) extends CarElement def print(elem: CarElement) = elem match { case Wheel(name) => println(“Visiting” + name + “ wheel”) case Engine => println(“Visiting engine”) case Body => println(“Visiting body”) case Car(elements) => elements foreach print; println(“Visiting car”) } def doSomething(elem: CarElement) = elem match { case Wheel(name) => println(“Kicking my ” + name + “ wheel”) case Engine => println(“Starting my engine”) case Body => println(“Moving my body”) case Car(elements) => elements foreach doSomething; println(“Starting my car”) } Scala ύλʔϯϚον
of the null reference in 1965. Tony Hoare (2009). “Null Reference: The Billion Dollar Mistake”. QCon London “null 10 ԯυϧͷࣦഊ” ※ʮΫΠοΫιʔτʯΛൃ໌ͨ͠ਓ Option ܕ
you forget ‘case None =>’... } warning: match may not be exhaustive. It would fail on the following input: None person match { ^ ίϯύΠϥ͕ ϛεΛݟ͚ͭͯܯࠂͯ͘͠ΕΔʂ Option ܕ ͏͔ͬΓ None Λ Εͯ… ίϯύΠϥ: ʮNone ͷఆ͕ٛແ͘ͳ͍ʁʯ