4. WARUM SCALA?
Scala, it must be stated, is the current
heir apparent to the Java throne.
Charles Nutter
5. WARUM SCALA?
I can honestly say if someone had shown me ... Scala ...
back in 2003 I'd probably have never created Groovy.
James Strachan
6. obje
eift kt-fu pis iert
a us ger nkti
ona tisc h ty
l sta
leich ark
tgew sst
icht
ig WAS IST SCALA? au sdr uck
knap inte
rope
p un
d pr ati sch rabe
äzis
e p ragm l mit
Java
11. AUSDRUCKSSTARK
"Calling Person.toString" when {
"first and last name are not-empty" should {
"return first name blank last name" in {
val person = new Person("John", "Doe")
person.toString should be ("John Doe")
}
}
}
12. KNAPP UND PRÄZISE
public class Person { // Java
private final String firstName;
private final String lastName;
public class Person(val firstName: String,
Person(String firstName, String lastName) {
val lastName: String)
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}
16. Any
AnyVal AnyRef
Int Unit ScalaObject
Long scala.* val scala.* ref java.* ref
Null
Nothing
ALLES IST EIN OBJEKT
17. Keine Seiteneffekte
1, 2, 3 f a, b, c
Funktionen höherer Ordnung
FUNKTIONALE PROGRAMMIERUNG
18. Klas
sen-
as sen Para thoden
Kl m eter M e
LIVE DEMO: OO-GRUNDLAGEN
Defa Com
ult-Ar pan
gum Fe lder ion
Obje
ente cts
19. rkz eug
st- We
Te
LIVE DEMO: SCALATEST
DSL
-Bei
spie
l
20. Für
Libr
ary-E
ntw
icklu
ng
LIVE DEMO: IMPLICIT CONVERSIONS
pra che
rbare S
Skalie
21. Unv
Type erän
Infe ato ren Obje
derl
iche
renc
e O per kte
LIVE DEMO: FUNKTIONALE LISTE
nen g Funk
ktio nun
Fun Ord
tion
slite tio nen
rer rale Funk
h öhe
22. Meh
rfac
hver
erbu
ng r
icht
ig ge
mac
ht
LIVE DEMO: TRAITS
ns
c atio
M odifi
ackabe
St
23. Upp ma cht Low
er B i g ge er Bo
ound i cht und
s eri cs r s
Gen
LIVE DEMO: TYP-PARAMETER
i anz
Kov
aria ari anz
In var nz trav
Kon
24. Swit
tern ch rich tern
Pat tig g Pat
d card ema nst ant
Wil c ht Co
LIVE DEMO: PATTERN MATCHING
Vari ern Seq
able att u ence
Patt t or P Patt
e rn st ruc ern
Con
25. pra che
er S
in d
L ite rale
LIVE DEMO: XML-SUPPORT
XPa
th-A
bfra
gen