🔴 Scala Intermediate

What is Scala 3 (Dotty) and its major changes?

Answer

Scala 3 (codenamed Dotty) is a major revision of Scala with cleaner syntax and improved type system. Key changes: given/using: replace implicits with explicit, readable syntax. given intShow: Show[Int] with { def show(n: Int) = n.toString }. extension methods: extension (n: Int) def doubled = n * 2; 5.doubled. Enum: first-class ADTs: enum Shape { case Circle(r: Double); case Rectangle(w: Double, h: Double) }. Union types: def f(x: Int | String). Intersection types: A & B. Opaque type aliases: opaque type Email = String. Context functions: type Builder = (Config) ?=> Unit. Match types: type-level pattern matching. Indentation-based syntax (Python-like, optional). Scala 3 addresses many criticisms of Scala 2's implicit system and provides a cleaner foundation for both OOP and functional programming.