Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scala 3 - A Quick Tour - Scala Italy 2021

Scala 3 - A Quick Tour - Scala Italy 2021

Daniela Sfregola

October 23, 2021
Tweet

More Decks by Daniela Sfregola

Other Decks in Programming

Transcript

  1. Hellooooo • Software Engineer 
 living in London UK •

    Scala Lover ❤ • OS Maintainer • Author of 
 "Get Programming with Scala" by Manning
 
 35% OFF on EVERYTHING
 with code "ctwscalait21"
  2. Scala 3 is here! • After 8 years of work

    • 28,000 commits • 7,400 pull requests • 4,100 closed issues • ...released on May 13th, 2021! https://www.scala-lang.org/blog/2021/05/14/scala3-is-here.html
  3. @main Annotation object HelloWorld extends App { println("Hello World!" )

    } object HelloWorld { @main def hello: Unit = { println("Hello world!" ) } }
  4. @main Annotation object HelloWorld extends App { println("Hello World!" )

    } object HelloWorld { @main def hello: Unit = { println("Hello world!" ) } } object Hello { @main def echo(n: Int, word: String): Unit = { println(word * n ) } }
  5. Package Object // in file my/demo/package.scal a package m y

    package object demo { def customLog(msg: String) { println(s"Customised package log: $msg" ) } }
  6. Package Object // in file my/demo/package.scal a package m y

    package object demo { def customLog(msg: String) { println(s"Customised package log: $msg" ) } } [ DROPPED ]
  7. Enums sealed abstract class Color(val rgb: Int)
 case object Red

    extends Color(0xFF0000 ) case object Green extends Color(0x00FF00 ) case object Blue extends Color(0x0000FF)
  8. Enums sealed abstract class Color(val rgb: Int)
 case object Red

    extends Color(0xFF0000 ) case object Green extends Color(0x00FF00 ) case object Blue extends Color(0x0000FF) enum Color(val rgb: Int) : case Red extends Color(0xFF0000 ) case Green extends Color(0x00FF00 ) case Blue extends Color(0x0000FF)
  9. Improved Error Messages Arrested Developers What the Scala Compiler &

    Lucille Bluth 
 Have In Common by Fiona Condon, NeScala 2017 https://www.youtube.com/watch?v=78iIbiRwFTM
  10. Improved Error Messages def echo(str: String): Unit = { st

    r } def echoTwice(str: String): String = { echo(str) match { case x: String => s"$x$x " } }
  11. Compatibility with 2.13 Migrating to Scala 3 is easy* !

    * if you are using Scala 2.13 * if you don't have macros in your code Scala 3 Migration Guide https://docs.scala-lang.org/scala3/guides/migration
  12. Thank You! •Twitter: @DanielaSfregola •"Get Programming with Scala" 
 by

    Manning
 
 35% OFF on EVERYTHING 
 with code "ctwscalait21"