Home / Scala
Scala
Scala beyond the basics: generics with bounds and variance, givens and type classes, extractors, deeper collections, Futures, and safe resources. Every example is verified with the real compiler.
Scala Intermediate starts where Scala Beginner stops. You already write Scala programs with classes, case classes, traits, match and Option. Across 48 lessons this level teaches you to design with the type system: methods that work for many types under stated bounds, givens that supply values by type, extractors that take values apart in patterns, collections used with judgement about cost, and background work handled through Futures. Two closing projects put it together: a command-line tool and a data pipeline.
Course contents
Work top to bottom — the sidebar is the course. Topics later in the list assume the ones before them.
Scala Intermediate Introduction
Intermediate · ⏱ 4 min · standalone lesson
Generics and Variance
- Scala Type Parameters
- Scala Upper Bounds
- Scala Lower Bounds
- Scala Variance
- Scala Generic Methods
- Scala Type Aliases
From Implicits to Givens
- Scala Given Instances
- Scala Using Clauses
- Scala Extension Methods
- Scala Type Classes
- Scala Context Bounds
- Scala Given Conversions
Pattern Matching in Depth
- Scala Extractors
- Scala Unapply Sequences
- Scala Sealed Hierarchies
- Scala Pattern Guards
- Scala Matching Collections
- Scala Nested Patterns
Collections in Depth
- Scala Views
- Scala Builders
- Scala Iterators
- Scala Collection Performance
- Scala Sorting and Ordering
- Scala Grouping and Zip
- Scala Maps in Depth
Functional Programming in Depth
- Scala Higher-Order Functions
- Scala Currying and Partial Application
- Scala For-Comprehensions
- Scala Option in Depth
- Scala Either in Depth
- Scala Try in Depth
- Scala Lazy Values
Concurrency Basics
- Scala Futures
- Scala Execution Context
- Scala Promises
- Scala Future Composition
- Scala Future Sequencing
- Scala Future Errors
Error Handling and Resource Safety
- Scala Exceptions in Depth
- Scala Resource Safety
- Scala Validation Accumulation
- Scala Error Design
- Scala Error Recovery
Testing and Tooling
Start: Scala Testing with Assert ❯Scala Project: Command-Line Tool
Intermediate · ⏱ 8 min · standalone lesson
Scala Project: Data Pipeline
Intermediate · ⏱ 8 min · standalone lesson
Learn Scala Intermediate
Beginner Scala is about writing programs that work. Intermediate Scala is about writing programs whose shape is checked before they run. A generic method with an upper bound refuses the wrong kind of value at compile time, not at run time. A sealed hierarchy lets a match cover every case, so a missing case is a compiler complaint rather than a crash on a customer's input. That shift, from code that runs to code that cannot go wrong in certain ways, is the whole level.
Givens are the centre of the level. Scala 3 replaced the old implicit machinery with givens: values the compiler finds by type, method parameters filled in with using, and extension methods that add readable syntax to existing types. Built on givens sit type classes, the pattern behind sorting, showing and comparing values across unrelated types. Once you can write a type class and summon its instance, large parts of library code that looked like magic become ordinary code you can read and write.
The rest of the level earns its keep in daily work. Views and builders keep big collections cheap. Option, Either and Try turn missing values and failures into values you can pass around instead of exceptions you must remember to catch. Futures move slow jobs into the background and recover from their failures without tangling the main flow. Using closes resources even when a block fails. The two projects at the end demand all of it at once: a tool that parses arguments and reports errors cleanly, and a pipeline that validates a whole batch, groups it, and prints totals a reader can check.
What you will learn
By the end of the course, the following are all things you can do in Scala:
- Write generic classes and methods, and fence them with upper and lower bounds so only fitting types pass.
- Read and write variance annotations, and say when a container of one type counts as a container of another.
- Supply values with givens, fill method parameters with using, and add syntax with extension methods.
- Build a type class with a trait and given instances, and use it through a context bound.
- Take values apart with extractors, including extractors that match a variable number of parts.
- Match sealed hierarchies exhaustively, guard patterns with conditions, and match inside collections and nested values.
- Keep collection work lazy with views, collect results with builders, and walk data once with iterators.
- Judge collection cost without a stopwatch: when prepending beats appending, and when an index lookup walks.
- Sort with a given ordering, group and split collections, and reshape maps without losing entries.
- Chain Option, Either and Try through flatMap and for-comprehensions, and finish by building a command-line tool and a data pipeline.
Who this Scala Intermediate course is for
This course is for readers who finished Scala Beginner, or who already write Scala with the same toolkit: values and strings, lists and maps, functions and lambdas, classes and case classes, traits and enums, match expressions and Option. If those ideas are new, start with Scala Beginner and come back. Nothing here re-teaches them.
It suits a reader who wants to read library code without guessing. Sorting that takes an ordering, JSON-style showing for a new type, a collection pipeline that stays lazy until forced: these stop looking like tricks once you have written the given instances and type classes yourself. The course also suits a reader moving toward backend or data work in Scala, where Futures and resource safety are everyday tools rather than advanced topics.
It is not a first programming course, and it is not a tour of frameworks. Everything here uses the Scala standard library only, so the ideas transfer to whatever library you pick up next, instead of tying you to one.
How this course works
The course has 48 lessons, and their estimates add up to 249 minutes, a little over four hours of reading and trying. Work top to bottom: later categories assume earlier ones, so a Futures lesson leans on for-comprehensions, and the data pipeline leans on validation from the errors category.
Each lesson is short. It opens with a plain definition, shows small programs that prove one idea each, and closes with a fuller program that pulls the pieces together. Each lesson closes with a question, and the solution gives the reasoning behind it, so a wrong guess still teaches something.
Each snippet and closing program went through the Scala 3 compiler, version 3.3.4, and ran twice, and the output shown on the page is exactly what the run printed. Futures examples wait for their values before printing, so nothing on the page depends on the order background jobs happen to finish in.
Scala is a compiled language, so the Try-it box shows the result instead of running the code in your browser. The Scastie playground link on each lesson runs Scala for real, and your progress through the course is saved in your browser as you go.
Frequently asked questions
Do I need Scala Beginner first?
Yes. The course builds on classes, case classes, traits, enums, match, Option, lambdas and map and filter, and never re-introduces them. Readers new to those ideas should take Scala Beginner first.
What Scala version does this course use?
Scala 3, version 3.3.4, in the Scala 3 indentation style. Scala 2 differences are noted only where a reader is likely to meet them, since the taught standard is Scala 3.
Do I need to install anything?
No. You read and follow the lessons in your browser, and the Scastie playground link on each lesson runs Scala for real when you want to experiment. Nothing is installed for this course.
Are Futures the same as threads?
No. A Future is a value that will hold a result later, while threads are the workers that run jobs. A Future runs its job on a worker pool called an execution context, and your code waits for the value with Await instead of managing threads by hand.
Does this course teach Akka, Cats or ZIO?
No. Everything here uses the Scala standard library only. Givens, type classes, Futures and resource safety are the foundations those libraries build on, so this level makes their documentation far easier to read.
What can I build after this course?
Programs that parse and validate input, transform and group data, run slow jobs in the background, and report errors cleanly. The two closing projects, a command-line tool and a data pipeline, are working examples of exactly that shape.
Next steps
- Scala ❯ — The prerequisite course: first programs, collections, functions, classes, case classes, traits, enums, match and Option.
- Kotlin Intermediate ❯ — Another language's intermediate level, for readers who want a second mid-level course after Scala.