- 01Setting up (what you'll need)
- 02Your first output (println)
- 03Variables (val and var)
- 04Type annotations and basic types
- 05Branching (the if expression)
- 06Repeating (the for expression)
- 07Writing your own function
- 08Repeating (the while loop)
- 09Working with lists (List)
- 10Working with maps (Map)
- 11Classes (object orientation)
- 12case class
- 13Inheritance and traits
- 14Pattern matching (the match expression)
- 15The Option type (null safety)
- 16Higher-order functions, map and filter
- 17object (singletons)
- 18Strings and string interpolation
- 19for comprehensions
- 20[Project] Build a small inventory system
[Project] Build a small inventory system
In this lesson you combine the case classes, lists, pattern matching, and higher-order functions covered so far into a simple inventory system. It is the capstone of this Scala introduction.
Real business systems use this combination constantly: represent something like a product with a case class, manage many of them in a List, and branch on state with a match expression.
The sample code represents a product (name and quantity) with case class Item, manages the product listing in a List, and prints a per-state message with a match expression.
Immutability, pattern matching, and higher-order functions — everything covered in these lessons — are the foundations you will design around in real systems and data processing. Getting into the habit of writing small programs in a functional style is the shortest path to using Scala professionally.
๐งช This site can't compile or run Scala directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ nothing is sent anywhere).
