6. 亠仄仆仂亞仂 亳仆亠亳从亳
def max(a,b) = if (a > b) a else b
class Person(val name: String, val age: Int) {
require(name.length != 0) //will generate exception
require(age > 0)
def and(that: Person): Love = new Love(this, that)
}
val Mike = new Person(Mike", 17)
val Jane = new Person("Jane", 23)
val love = Mike and Jane
7. //Java
import java.util.ArrayList;
Person[] people;
Person[] minors;
Person[] adults;
{
ArrayList<Person> minorsList = new ArrayList<Person>();
ArrayList<Person> adultsList = new ArrayList<Person>();
for (int i = 0; i < people.length; i++)
(people[i].age < 18 ? minorsList : adultsList)
.add(people[i]);
minors = minorsList.toArray(people);
adults = adultsList.toArray(people);
}
//Scala
val people: Array[Person]
val (minors, adults) = people partition(_.age > 18)
8. 亟亳亳
Trading platforms
Financial modeling
Simulation
domain-specific languages
Web platforms
Play Framework
Lift