Skip to content
Tutorials Center
My learning

Topics

Scala Tutorial

Learn Scala step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Scala? Learn what Scala is, why it blends object-oriented and functional programming on the JVM, what Scala 3 changed, and where Scala is used in real projects.
  2. 2 Install Scala and Run Code Install Scala 3 with Coursier, scala-cli and sbt, run your first file, use the REPL, and pick an editor such as IntelliJ IDEA or VS Code with Metals.
  3. 3 Your First Scala Program Write your first Scala 3 program: the @main annotation, println, command-line arguments, top-level definitions, and what the older object-with-main style looks like.
  4. 4 Syntax Rules and Comments Learn Scala 3 syntax basics: significant indentation vs braces, blocks as expressions, naming rules and conventions, keywords, comments and Scaladoc documentation.

Language Basics

  1. 5 Values, Variables and Types Learn val vs var, type inference, lazy val, the basic Scala types (Int, Long, Double, Boolean, Char, String), numeric conversions and the Any type hierarchy.
  2. 6 Operators and Strings Learn Scala operators as methods, precedence, equality with ==, and strings: s, f and raw interpolators, multiline strings, common String methods and StringBuilder.
  3. 7 Control Flow as Expressions Learn Scala 3 control flow: if/then/else and match as expressions that return values, guards, the Unit result of if without else, and try/catch/finally.
  4. 8 Loops and For Comprehensions Learn Scala 3 for loops and for comprehensions: ranges, guards, nested generators, yield, foreach vs map, while, and how for desugars into map and flatMap.
  5. 9 Methods and Functions Learn Scala def methods, default and named arguments, varargs, function values and lambdas, higher-order functions, currying, by-name parameters and closures.

Collections

  1. 10 Arrays, Seq and Buffers Tour the Scala collections library: immutable vs mutable, the Seq hierarchy, Array, ArrayBuffer, indexing, updating, sorting and when to pick each sequence type.
  2. 11 Lists and Vectors Master Scala's List and Vector: building with :: and Nil, head and tail, pattern matching on lists, recursion, performance trade-offs, LazyList and common operations.
  3. 12 Sets and Maps Learn Scala Set and Map: creating, adding and removing elements, safe lookup with get and getOrElse, iterating, grouping, counting words, and mutable vs immutable versions.
  4. 13 Transforming Collections Learn the core Scala collection methods: map, filter, flatMap, foldLeft, reduce, zip, partition, groupBy, sortBy, take/drop and views, with worked examples and diagrams.
  5. 14 Tuples, Options and Ranges Learn Scala tuples for grouping values, Option to model missing values without null, safe handling with map, getOrElse and pattern matching, and Range, Iterator and LazyList basics.

Classes, Traits and Objects

  1. 15 Classes and Constructors Learn how to define Scala 3 classes: primary and auxiliary constructors, val and var parameters, private members, methods, toString, equality, and creator applications without new.
  2. 16 Singleton Objects and Companions Learn Scala's singleton object, companion objects for static-like members and factories, apply and unapply, private constructors, and how objects replace Java static.
  3. 17 Inheritance and Abstract Classes Learn Scala inheritance: extends, override, super, abstract classes and members, polymorphism, final, sealed and the Scala 3 open modifier, with diagrams and examples.
  4. 18 Traits and Mixins Learn Scala traits: abstract and concrete members, mixing in several traits, stackable behaviour, linearization order, trait parameters, and when to use a trait or abstract class.
  5. 19 Packages, Imports and Access Control Learn Scala packages and imports (wildcards, renaming, selectors), package objects and top-level definitions, access modifiers private and protected, and qualified private[scope].

Case Classes and Pattern Matching

  1. 20 Scala Case Classes Learn Scala 3 case classes: automatic equals, toString, copy and apply, immutable modeling, case objects, and how they compare with Java records.
  2. 21 Pattern Matching in Scala Master Scala 3 pattern matching: match expressions, literal, variable, type and tuple patterns, guards, alternatives, and how matching differs from switch.
  3. 22 Scala Enums, Sealed Traits and ADTs Model data precisely with Scala 3 enums, sealed traits and algebraic data types, and let the compiler check that every case is handled in a match.
  4. 23 Scala Extractors and Advanced Patterns Go beyond basic matching in Scala 3: write custom extractors with unapply and unapplySeq, match regular expressions, and use partial functions and collect.

Functional Programming

  1. 24 Immutability and Pure Functions in Scala Understand functional programming in Scala: immutable values, pure functions, referential transparency, side effects, recursion and tail recursion with @tailrec.
  2. 25 Higher-Order Functions and Currying in Scala Learn Scala functions as values: lambdas, function types, map, filter and fold, closures, composition with andThen, partial application and currying.
  3. 26 Option, Either and Try in Scala Handle missing values and errors without null or exceptions in Scala: Option, Some, None, Either, Left, Right and Try with map, flatMap, fold and recover.
  4. 27 Scala For-Comprehensions Explained Understand Scala for-comprehensions: loops, yield, guards, nested generators, how they desugar into map, flatMap and withFilter, and use with Option, Either and Future.
  5. 28 Scala 3 Type Classes, Givens and Extension Methods Learn Scala 3 contextual abstractions: given instances, using clauses, context bounds, extension methods and the type class pattern for flexible, reusable code.

Concurrency and Futures

  1. 29 Scala Futures and Promises Write asynchronous Scala code with Future and Promise: execution contexts, map and flatMap, for-comprehensions, parallel futures, error recovery and timeouts.
  2. 30 Threads, Synchronization and Atomics in Scala Use JVM threads from Scala: Thread, executors, race conditions, synchronized, volatile, AtomicInteger, concurrent collections, deadlocks and virtual threads.
  3. 31 Scala Actors, Pekko, cats-effect and ZIO Tour the main Scala concurrency models beyond Future: actors with Apache Pekko, lazy effects with cats-effect IO and ZIO, plus streams, and how to choose between them.

Tools and Ecosystem

  1. 32 sbt and Scala Project Setup Set up Scala 3 projects with sbt: directory layout, build.sbt, dependencies with %%, compiler options, tasks, multi-module builds, plugins, and Scala CLI as a lighter option.
  2. 33 Testing in Scala: munit, ScalaTest and ScalaCheck Test Scala 3 code with munit and ScalaTest: assertions, exceptions, async tests, fixtures, property-based testing with ScalaCheck, and how pure functions make tests simple.
  3. 34 Scala and Java Interoperability Use Java libraries from Scala and Scala from Java: collection converters, null and Optional handling, lambdas, exceptions, varargs, plus Scala.js, Scala Native and key libraries.

Projects and Practice

  1. 35 Project: Word Frequency Counter in Scala Build a word frequency counter in Scala 3 step by step: tokenizing, groupMapReduce, ranking, stop words, formatted output, file input and tests, with a runnable Java and Kotlin version.
  2. 36 Project: Expression Evaluator in Scala Build a calculator in Scala 3: tokenizer, recursive-descent parser, an enum AST, an evaluator with Either errors, and tests. A runnable Java version shows the same design.
  3. 37 Scala Practice Problems with Solutions Twelve Scala 3 practice problems with hints and solutions: case classes, pattern matching, Option and Either, folds, tail recursion, lazy lists, futures and type classes.