Employee { def delegate(d: Developer): Unit = println(d) } Can be used like interfaces Can be mixed in with classes and objects Supports multiple inheritance using trait linearization
class Country(name: String) object Country { val codes: Map[Int, String] = ??? def apply(code: Int) = Country(codes(code)) def printCountry(c: Country) = println(c) } object CountryKeys extends Enumeration { val IN, US = Value val UK = Value("uk") }
uence on our thinking habits, and, therefore, on our thinking abilities -- Edsger Dijkstra, How do we tell truths that might hurt? “ “ Don't you hate code that's not properly indented? Making it part of the syntax guarantees that all code is properly indented! -- Guido van Rossum “ “
North extends Direction case object East extends Direction case object West extends Direction case object South extends Direction De nes a base type that can refer to any of its implementations Typically functions would take elements of base type as argument and gure out underlying implementation inside it
extends Tree[T] case class Node[T](l: Tree[T], r: Tree[T]) extends Tree[T] Can be thought of as a combination of Product and Sum types Can de ne bounds and ensure typesafety for generic inputs
starting point to get familiar with the syntax 2. Scala Exercises - Practise and learn Scala 3. Scala Levels - Conceptual milestones postulated by Martin Odersky 4. Learn you a Haskell for Great Good! - The most fun resource for indepth understanding of functional programming 5. Functional Programming in Scala - If you're someone who prefers a structured way of learning 6. Scala Cookbook - Highly useful if you want to get shit done in scala
in Scala 3. Functional programming with Typeclasses 4. cats - a modular and extensible library for functional programming 5. Uncle Bob's Bowling Game Kata 6. Publishing an SBT project to Bintray 7. Marp, Markdown PPT editor 8. Source code of demo project