0
SCALA <br />fra newbie til ninja på en time<br />Nina Heitmann<br />nina.heitmann@iteraconsulting.no<br />@ninaheitmann<br...
publicclass Dog {<br />private final String name;<br />private intage;<br />public Dog(String name, int age) {<br />this.n...
class Dog(val name : String, var age : Int){<br />def bark = println(”Woof woof!”)<br />}<br />
object DateUtil {<br />def formatDate = {<br />    ...<br />  }<br />}<br />
class Dog (val name : String,<br />varage : Int)<br />object Dog {<br />def maximumAge = 12<br />}<br />
class Dog(val name : String, var age : Int)<br />class Dog(val name : String, var age : Int) {<br />  println(”Creating Do...
var name : String = "Harald"<br />var name = "Harald"<br />name = 6// Kompileringsfeil<br />
def square(x : Int) : Int = { x*x } // Int<br />def square(x : Int) = x*x           // Int<br />def square(x : Int) { x*x ...
2+3<br />2.+(3)<br />
val num = 8// Int<br />val isValid = true// Boolean<br />
for(Integer element : list) {<br />	System.out.println(element);<br />}<br />list.foreach(element => <br />println(element...
for(Integer element : list) {<br />	System.out.println(element);<br />}<br />list.foreach(element =>  <br />println(elemen...
val list = List(1, 2, 3, 4, 5)<br />list.filter(element => <br />               element < 3)<br />   // List(1, 2)<br />li...
int sum = 0;<br />for(Integer current : list) {<br />	sum += current;<br />}<br />val list = List(1, 2, 3, 4, 5)<br />list...
int sum = 0;<br />for(Integer current : list) {<br />sum += current;<br />}<br />val list = List(1, 2, 3, 4, 5)<br />list....
DON’T TRY THIS AT HOME!<br />http://www.flickr.com/photos/94507863@N00/1108110035<br />
Scala 2.8.0<br />9.0.3<br />+ siste plugin!<br />
Byggeverktøy<br />Maven<br />Simple Build <br />Tool (SBT)<br />
http://www.github.com/karianne<br />	- sbt-minimal-example<br />   - mvn-minimal-example<br />
http://www.scala-lang.org<br />http://scala.java.no<br />http://www.google.com <br />
Onsdag 13:00	Pattern matching<br />Onsdag 14:15	Akka<br />Torsdag 13:00	Lift<br />Torsdag 17:00	Actors i produksjon<br />
16.-17. november i Oslo<br />www.smidig2010.no<br />
Karianne Berg<br />karianne@miles.no<br />@karianneberg<br />Nina Heitmann<br />nina.heitmann@iteraconsulting.no<br />@nin...
Upcoming SlideShare
Loading in...5
×

Scala - fra newbie til ninja på en time

738

Published on

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
738
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide
  • Det er noen tilfeller der man må oppgi typen til variabelen
  • Husk å nevne at man kan kutte ut punktum og parenteser i metodekall
  • Gjør operasjoner på collections uten muterbare variablerMuterer ikke listene, men returnerer en ny immutable liste med elementene som skal være med
  • Gjør operasjoner på collections uten muterbare variablerMuterer ikke listene, men returnerer en ny immutable liste med elementene som skal være med
  • Her bør jeg kanskje gidde å poppe opp tekstbokser over de &quot;fargede&quot; ordene (som da ikke er farget) med fargede ord.
  • Transcript of "Scala - fra newbie til ninja på en time"

    1. 1. SCALA <br />fra newbie til ninja på en time<br />Nina Heitmann<br />nina.heitmann@iteraconsulting.no<br />@ninaheitmann<br />Karianne Berg<br />karianne@miles.no<br />@karianneberg<br />
    2. 2. publicclass Dog {<br />private final String name;<br />private intage;<br />public Dog(String name, int age) {<br />this.name = name;<br />this.age = age;<br /> }<br />public String getName = { return name; }<br />publicint getAge = { return age; }<br />public void setAge(int age) { <br />this.age = age; <br />}<br />public void bark() { <br /> System.out.println(”woof woof!”); <br /> }<br />}<br />
    3. 3. class Dog(val name : String, var age : Int){<br />def bark = println(”Woof woof!”)<br />}<br />
    4. 4. object DateUtil {<br />def formatDate = {<br /> ...<br /> }<br />}<br />
    5. 5. class Dog (val name : String,<br />varage : Int)<br />object Dog {<br />def maximumAge = 12<br />}<br />
    6. 6. class Dog(val name : String, var age : Int)<br />class Dog(val name : String, var age : Int) {<br /> println(”Creating Dog”)<br />}<br />class Dog(val name : String, var age : Int) {<br />def this(name : String) = this(name, 10)<br /> // Kompileringsfeil<br />def this(name : String) = println(”Dog!”)<br />}<br />class Dog private(val name : String, <br />var age : Int)<br />
    7. 7. var name : String = "Harald"<br />var name = "Harald"<br />name = 6// Kompileringsfeil<br />
    8. 8. def square(x : Int) : Int = { x*x } // Int<br />def square(x : Int) = x*x // Int<br />def square(x : Int) { x*x } // Unit(!)<br />
    9. 9. 2+3<br />2.+(3)<br />
    10. 10. val num = 8// Int<br />val isValid = true// Boolean<br />
    11. 11. for(Integer element : list) {<br /> System.out.println(element);<br />}<br />list.foreach(element => <br />println(element)<br />)<br />
    12. 12. for(Integer element : list) {<br /> System.out.println(element);<br />}<br />list.foreach(element => <br />println(element)<br />)<br />list.foreach(println(_))<br />
    13. 13. val list = List(1, 2, 3, 4, 5)<br />list.filter(element => <br /> element < 3)<br /> // List(1, 2)<br />list.filter(_ < 3)<br /> // List(1, 2)<br />
    14. 14. int sum = 0;<br />for(Integer current : list) {<br /> sum += current;<br />}<br />val list = List(1, 2, 3, 4, 5)<br />list.foldLeft(0) { (sum, current) => sum + current}<br /> // 15<br />
    15. 15. int sum = 0;<br />for(Integer current : list) {<br />sum += current;<br />}<br />val list = List(1, 2, 3, 4, 5)<br />list.foldLeft(0) { (sum, current) => sum + current}<br /> // 15<br />list.foldLeft(0) {_ + _}<br /> // 15<br />sum<br />0<br />Integer current<br />sum += current;<br />0<br />sum<br />current<br />sum + current<br />
    16. 16.
    17. 17. DON’T TRY THIS AT HOME!<br />http://www.flickr.com/photos/94507863@N00/1108110035<br />
    18. 18. Scala 2.8.0<br />9.0.3<br />+ siste plugin!<br />
    19. 19. Byggeverktøy<br />Maven<br />Simple Build <br />Tool (SBT)<br />
    20. 20.
    21. 21. http://www.github.com/karianne<br /> - sbt-minimal-example<br /> - mvn-minimal-example<br />
    22. 22. http://www.scala-lang.org<br />http://scala.java.no<br />http://www.google.com <br />
    23. 23.
    24. 24. Onsdag 13:00 Pattern matching<br />Onsdag 14:15 Akka<br />Torsdag 13:00 Lift<br />Torsdag 17:00 Actors i produksjon<br />
    25. 25. 16.-17. november i Oslo<br />www.smidig2010.no<br />
    26. 26. Karianne Berg<br />karianne@miles.no<br />@karianneberg<br />Nina Heitmann<br />nina.heitmann@iteraconsulting.no<br />@ninaheitmann<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×