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

More Related Content

What's hot

Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
 
Doctrineのメモリーリークについて
DoctrineのメモリーリークについてDoctrineのメモリーリークについて
Doctrineのメモリーリークについて
t satoppejp
 

What's hot (20)

Kotlin
KotlinKotlin
Kotlin
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 
Kotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functionsKotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functions
 
The Ring programming language version 1.7 book - Part 25 of 196
The Ring programming language version 1.7 book - Part 25 of 196The Ring programming language version 1.7 book - Part 25 of 196
The Ring programming language version 1.7 book - Part 25 of 196
 
Kotlin, why?
Kotlin, why?Kotlin, why?
Kotlin, why?
 
Coffee Scriptでenchant.js
Coffee Scriptでenchant.jsCoffee Scriptでenchant.js
Coffee Scriptでenchant.js
 
[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8
 
The basics and design of lua table
The basics and design of lua tableThe basics and design of lua table
The basics and design of lua table
 
Swift Rocks #2: Going functional
Swift Rocks #2: Going functionalSwift Rocks #2: Going functional
Swift Rocks #2: Going functional
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
Swift rocks! #1
Swift rocks! #1Swift rocks! #1
Swift rocks! #1
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Doctrineのメモリーリークについて
DoctrineのメモリーリークについてDoctrineのメモリーリークについて
Doctrineのメモリーリークについて
 
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!
 
The Ring programming language version 1.5.4 book - Part 23 of 185
The Ring programming language version 1.5.4 book - Part 23 of 185The Ring programming language version 1.5.4 book - Part 23 of 185
The Ring programming language version 1.5.4 book - Part 23 of 185
 
Comparing JVM languages
Comparing JVM languagesComparing JVM languages
Comparing JVM languages
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Fun with Kotlin
Fun with KotlinFun with Kotlin
Fun with Kotlin
 
Pickle - how it works
Pickle - how it worksPickle - how it works
Pickle - how it works
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
 

Similar to Scala - fra newbie til ninja på en time

About java
About javaAbout java
About java
Jay Xu
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
mallik3000
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
arrowmobile
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
fantasiatheoutofthef
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
Codecamp Romania
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
Loïc Descotte
 

Similar to Scala - fra newbie til ninja på en time (20)

かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
About java
About javaAbout java
About java
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+k
 
Introduction kot iin
Introduction kot iinIntroduction kot iin
Introduction kot iin
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
 
6. Generics. Collections. Streams
6. Generics. Collections. Streams6. Generics. Collections. Streams
6. Generics. Collections. Streams
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin WayTDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlin
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Scala - fra newbie til ninja på en time

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

Editor's Notes

  1. Det er noen tilfeller der man må oppgi typen til variabelen
  2. Husk å nevne at man kan kutte ut punktum og parenteser i metodekall
  3. Gjør operasjoner på collections uten muterbare variablerMuterer ikke listene, men returnerer en ny immutable liste med elementene som skal være med
  4. Gjør operasjoner på collections uten muterbare variablerMuterer ikke listene, men returnerer en ny immutable liste med elementene som skal være med
  5. Her bør jeg kanskje gidde å poppe opp tekstbokser over de &quot;fargede&quot; ordene (som da ikke er farget) med fargede ord.