Recap of day 1
Variables Scala: val s = “Hello World” var i = 1 Java: public final String s = “Hello World”; public int i = 1;
Methods Scala: def add(x: Int, y: Int): Int = { x + y } def add(x: Int, y: Int) = x + y def doSomething(text: String) { } Java: public int add(int x, int y) { return x + y; } public void doSometing(String text) { }
Classes and constructors Scala: class Person(val name: String) Java: public class Person { private final String name; public Person(String name) { this.name = name; } public String getName() { return name; } }
Tuples Scala: val tuple: Tuple2[Int, String] =  (1, “apple”) val quadruple =  (2, “orange”, 0.5d, false) Java: Pair<Integer, String> tuple =  new Pair<Integer, String>(1, “apple”) ... yeah right... ;-)
The Option type val   someOption :  Option [ String ] =  Some ( &quot;value&quot; ) val   noOption :  Option [ String ] =  None
First class funtions val numbers = List(1, 2, 3, 4, 5) numbers.filter(i => i > 2) // List(3, 4, 5)
Closures val people = List(Person(“Alf”), Person(“Fredrik”)) val  name  = “Fredrik” people.filter(_.name ==  name ) // Person(“ Fredrik”)
val  myObject  = ...  val  res  =  myObject   match  { case   i :  Int  if  i  == 1  =>  &quot;Found an int which is 1&quot; case   s :  String  =>  &quot;Found a String&quot; case   other  =>  error ( &quot;Unknown &quot;  +  other ) } Pattern matching
Traits trait Ordered[A] { def compare(that: A): Int def <  (that: A): Boolean = ( this  compare that) <  0 def >  (that: A): Boolean = ( this  compare that) >  0 def <= (that: A): Boolean = ( this  compare that) <= 0 def >= (that: A): Boolean = ( this  compare that) >= 0 }
Todays schedule Higher order functions

More Related Content

ODP
1.2 Scala Basics
PDF
Swift rocks! #1
PDF
A Prelude of Purity: Scaling Back ZIO
PDF
Swift Rocks #2: Going functional
PDF
High Wizardry in the Land of Scala
PDF
ハイブリッド言語Scalaを使う
ODP
1.5 pattern matching
PDF
Exploring ZIO Prelude: The game changer for typeclasses in Scala
1.2 Scala Basics
Swift rocks! #1
A Prelude of Purity: Scaling Back ZIO
Swift Rocks #2: Going functional
High Wizardry in the Land of Scala
ハイブリッド言語Scalaを使う
1.5 pattern matching
Exploring ZIO Prelude: The game changer for typeclasses in Scala

What's hot (19)

PPTX
Java Polymorphism Part 2
PPTX
Scala - fra newbie til ninja på en time
PPT
Scala presentation by Aleksandar Prokopec
KEY
ぐだ生 Java入門第一回(equals hash code_tostring)
PDF
Scala cheatsheet
PPTX
python beginner talk slide
PDF
Datastruct2
PDF
Fun never stops. introduction to haskell programming language
PPT
Groovy unleashed
PDF
Functional Programming & Event Sourcing - a pair made in heaven
ODP
1.2 scala basics
PDF
Demystifying Shapeless
KEY
Metaprogramming in Haskell
PDF
Tip Top Typing - A Look at Python Typing
PDF
Simple Neural Network Python Code
PPTX
Session 05 cleaning and exploring
PDF
Python programming : Inheritance and polymorphism
PDF
Talk Code
Java Polymorphism Part 2
Scala - fra newbie til ninja på en time
Scala presentation by Aleksandar Prokopec
ぐだ生 Java入門第一回(equals hash code_tostring)
Scala cheatsheet
python beginner talk slide
Datastruct2
Fun never stops. introduction to haskell programming language
Groovy unleashed
Functional Programming & Event Sourcing - a pair made in heaven
1.2 scala basics
Demystifying Shapeless
Metaprogramming in Haskell
Tip Top Typing - A Look at Python Typing
Simple Neural Network Python Code
Session 05 cleaning and exploring
Python programming : Inheritance and polymorphism
Talk Code
Ad

Viewers also liked (7)

PPT
Abbreviations
XLS
Trabajo 5 ... Actual
PPT
Guy Fawkes And The Gunpowder Plot
PPT
Hallowe’En In Northen Ireland
PPTX
Managing change for the next generation organization
PPT
Bancopopularnovember302009proposalpresentationforgallowayetc 091201153819 Php...
PPT
ARO MODERNOKO ARTEA
Abbreviations
Trabajo 5 ... Actual
Guy Fawkes And The Gunpowder Plot
Hallowe’En In Northen Ireland
Managing change for the next generation organization
Bancopopularnovember302009proposalpresentationforgallowayetc 091201153819 Php...
ARO MODERNOKO ARTEA
Ad

Similar to 2.1 Recap From Day One (20)

ODP
Scala introduction
PPTX
Scala - where objects and functions meet
PPT
Scala for Java Developers
PPT
JBUG 11 - Scala For Java Programmers
PPT
Scala introduction
PPTX
Scala en
PPTX
Scala: Devnology - Learn A Language Scala
PPTX
Practically Functional
PPTX
Scala in a Java 8 World
PPT
SDC - Einführung in Scala
PPTX
A Brief Intro to Scala
ODP
2.1 recap from-day_one
PDF
Scala vs Java 8 in a Java 8 World
PPTX
Oscon 2010 Specs talk
PPT
Scala Language Intro - Inspired by the Love Game
PPT
The Kotlin Programming Language
PDF
여자개발자모임터 6주년 개발 세미나 - Scala Language
PDF
Pragmatic Real-World Scala
PDF
Pragmatic Real-World Scala (short version)
PDF
Scala or functional programming from a python developer's perspective
Scala introduction
Scala - where objects and functions meet
Scala for Java Developers
JBUG 11 - Scala For Java Programmers
Scala introduction
Scala en
Scala: Devnology - Learn A Language Scala
Practically Functional
Scala in a Java 8 World
SDC - Einführung in Scala
A Brief Intro to Scala
2.1 recap from-day_one
Scala vs Java 8 in a Java 8 World
Oscon 2010 Specs talk
Scala Language Intro - Inspired by the Love Game
The Kotlin Programming Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
Pragmatic Real-World Scala
Pragmatic Real-World Scala (short version)
Scala or functional programming from a python developer's perspective

Recently uploaded (20)

PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPT
Geologic Time for studying geology for geologist
PPTX
Tartificialntelligence_presentation.pptx
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
CloudStack 4.21: First Look Webinar slides
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Unlock new opportunities with location data.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Getting Started with Data Integration: FME Form 101
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Group 1 Presentation -Planning and Decision Making .pptx
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Geologic Time for studying geology for geologist
Tartificialntelligence_presentation.pptx
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Benefits of Physical activity for teenagers.pptx
CloudStack 4.21: First Look Webinar slides
Zenith AI: Advanced Artificial Intelligence
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Final SEM Unit 1 for mit wpu at pune .pptx
Unlock new opportunities with location data.pdf
1 - Historical Antecedents, Social Consideration.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
sustainability-14-14877-v2.pddhzftheheeeee
NewMind AI Weekly Chronicles – August ’25 Week III
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Hindi spoken digit analysis for native and non-native speakers
Getting Started with Data Integration: FME Form 101
Enhancing emotion recognition model for a student engagement use case through...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf

2.1 Recap From Day One

  • 2. Variables Scala: val s = “Hello World” var i = 1 Java: public final String s = “Hello World”; public int i = 1;
  • 3. Methods Scala: def add(x: Int, y: Int): Int = { x + y } def add(x: Int, y: Int) = x + y def doSomething(text: String) { } Java: public int add(int x, int y) { return x + y; } public void doSometing(String text) { }
  • 4. Classes and constructors Scala: class Person(val name: String) Java: public class Person { private final String name; public Person(String name) { this.name = name; } public String getName() { return name; } }
  • 5. Tuples Scala: val tuple: Tuple2[Int, String] = (1, “apple”) val quadruple = (2, “orange”, 0.5d, false) Java: Pair<Integer, String> tuple = new Pair<Integer, String>(1, “apple”) ... yeah right... ;-)
  • 6. The Option type val someOption : Option [ String ] = Some ( &quot;value&quot; ) val noOption : Option [ String ] = None
  • 7. First class funtions val numbers = List(1, 2, 3, 4, 5) numbers.filter(i => i > 2) // List(3, 4, 5)
  • 8. Closures val people = List(Person(“Alf”), Person(“Fredrik”)) val name = “Fredrik” people.filter(_.name == name ) // Person(“ Fredrik”)
  • 9. val myObject = ... val res = myObject match { case i : Int if i == 1 => &quot;Found an int which is 1&quot; case s : String => &quot;Found a String&quot; case other => error ( &quot;Unknown &quot; + other ) } Pattern matching
  • 10. Traits trait Ordered[A] { def compare(that: A): Int def < (that: A): Boolean = ( this compare that) < 0 def > (that: A): Boolean = ( this compare that) > 0 def <= (that: A): Boolean = ( this compare that) <= 0 def >= (that: A): Boolean = ( this compare that) >= 0 }
  • 11. Todays schedule Higher order functions