
Please download the exercises attached to this lecture and unzip them somewhere on your machine where you can find them later. Also if you have not already done so, please follow the free course instructions at https://www.udemy.com/stairway-to-scala-setup-instructions/learn/#/ so that you are ready to run both the Scala REPL and the exercises when the time comes.
Thanks and enjoy the course. This is only part one of three, the second and third parts go further into using Scala on a daily basis for your programming.
Begin your Scala journey in module one, practicing sbt, repl, and language basics, and follow the free Udemy setup course to ensure everything works.
Compare Scala's val and var: vals are immutable and cannot be reassigned, while vars are mutable, and the repl shows how new scopes can hide previous vals.
Explore that in Scala applied, part 1, if is an expression you can assign a value with val newName if args.length > 0 else default.txt, avoiding var and ternary operator.
Demonstrates how if expressions return values and can be used as expressions or statements, emphasizing functional style with minimal side effects.
Explore functional style in Scala by using worksheets in IntelliJ to implement max squared double, demonstrate try-catch-finally expressions, and reveal type inference and expression-based programming practices.
Create a Scala script times tables using nested while loops 1 to 5, 25 lines, with string interpolation, and use toString and contains to filter lines with 4 or 6.
Advance your Scala basics in part one, module two, by exploring language fundamentals, using worksheets, and running exercises in IntelliJ with a collaborative setup activity.
Introduce IntelliJ Community Edition as the recommended IDE, explore Scala worksheets with demos, and cover method parameters, return types, expressions versus statements, tuples, rewriting rules, collections, and implicit extension methods.
Import and configure the Scala project in IntelliJ by unzipping exercises, running sbt compile, ensuring a valid JDK, and building modules to evaluate worksheets.
Explore how to use IntelliJ worksheets to run Scala code interactively, and use src instead of Scala to avoid compiling top-level expressions.
Learn how to define methods with parameters and return types in Scala, compare explicit and inferred returns, and understand why parameter types cannot be omitted.
Learn that Scala uses unit for no-return behavior, not void. Always include the equals in method definitions to avoid silent unit results, and note that procedure syntax is deprecated.
Explore how expressions return a payload with a type, while statements yield unit through side effects. See how control constructs differ and why functional style favors expressions.
Explore how Scala val and var assignments can yield unit return types, and avoid patterns that return unit. Learn to set multiple values at once and spot common pitfalls.
Explore how tuples group multiple return values in Scala, returning int pairs for sum and difference, accessing elements with underscore notation and deconstructing them with val bindings.
Explore Scala's rewriting rules that enable infix notation for a single-parameter method, showing how dot notation, map on lists, and charAt form same call and when an instance is required.
Explore how the Scala apply method acts as a universal rewriting rule, enabling array creation, indexing, and intuitive method dispatch when parentheses are present.
Explore how mutable arrays in Scala use an update method instead of apply, rewriting assignments like args(0) = John to update(0, John) with unit return and side effects.
Learn how Scala rewriting rules ensure type checking and why an attempted rewrite may fail to compile. See how immutable lists show no update method, illustrating rewriting behavior.
Explore the Scala collections API, including mutable arrays and immutable lists, and learn how type parameters and type inference shape collection usage and method signatures.
Compare sequences and sets in Scala: arrays and vectors are ordered sequences with duplicates, while sets enforce uniqueness and may not preserve insertion order, using hash or tree variants.
Explore mutable versus immutable collections in Scala, comparing arrays, lists, vectors, and sets, and learn how var and val, plus equals, and rewrite rules govern updates.
Learn how Scala maps function as associative sequences with mutable and immutable variants, explore different implementations, and see how arrow syntax and extension methods manage key-value updates.
Favor expressions with no side effects, use vals and immutability, avoid vars, prevent mutability from leaking into APIs, keep methods short and single purpose, avoid premature optimization.
Open and read a file in Scala using scala.io.Source to obtain lines with getLines and iterate. This demo-focused approach aids learning and exercises, though not common in production.
Learn to run and fix module 2 Scala exercises in IntelliJ, making tests pass and using dot deep to compare arrays. Understand array equality quirks and progress toward list immutability.
Explore core Scala concepts by examining classes, objects, and applications. Learn the ins and outs of the language itself.
Define classes and constructors, explore parameters and fields, and illustrate with a rational number class. Examine preconditions, self reference, infix notation, operator overloading, auxiliary constructors, companion objects, and implicit conversions.
Learn to define a Scala class with the class keyword, include fields and methods in the body, instantiate with new, and see initialization code run.
Learn how the primary constructor in Scala supplies parameters and keeps them private inside the class, with a demo of creating instances and exposing parameters for external use.
define a rational number class in scala with two parametric fields n and d representing numerator and denominator, override toString for readable fraction, and handle zero denominator.
Explore checking preconditions in Scala by using require to prevent zero denominators, triggering illegal argument exceptions, and embracing early failure with an optional string field.
Explore a rational class with parametric fields, a toString, and a min method that compares two rationals using double precision, and reference the current instance with this.
Renaming a method to plus demonstrates that symbolic method names work like ordinary ones in Scala. Use symbolic names judiciously, avoiding meaningless or crazy operators.
Learn to construct a rational from an int with an auxiliary constructor in scala, using def this to call another this, and consider factory methods as a better alternative.
Make the primary constructor private and let the companion object access it, so factory methods control instance creation and enforce an idiomatic Scala API.
Explore method overloading in Scala by defining multiple plus methods for rational and int, using companion objects for conversions, and examining why five plus a half requires a different approach.
Learn how implicit conversions in Scala enable adding a rational to an int by using an implicit method in companion objects, making five plus one half work automatically.
Explore implicit rules in Scala by enabling the language feature with import, using implicit conversions to solve type puzzles from int to rational, and leveraging implicits in companion objects.
Implement a complex number class to make the module three tests pass after uncommenting them, guided by lessons on objects, companion objects, overloading constructors, and implicits.
Explore the remaining control structures in Scala, completing the language feature overview after covering classes, and prepare for future modules featuring new or unique language features.
Review expressions versus statements and the unit type in Scala, then cover if expressions, val and var, try-catch-finally, while loops, for expressions, match expressions with guards, and string interpolation.
Clarify expressions versus statements in Scala, explaining that expressions return a value while statements yield unit. Discuss referential transparency and how pure expressions avoid unintended side effects.
Explore how the Scala unit return type enforces side effects and how expressions differ from statements, including returning unit or returning this for fluent chaining.
Learn how to return values beyond unit in scala with a file writer example, using open close friends to signal side effects and manage resource lifecycles.
Explains returning this instead of unit to enable fluent API chaining with a writer output; writes strings and returns the same reference, offering a fluent, though not referentially transparent, pattern.
Contrast Java's if as a statement with no return value to Scala's single if expression that doubles as a statement or expression, and removes ternary operator, supporting vals and immutability.
Explore val versus var in scala and how the IDE flags mutable variables. Customize IntelliJ color hints to highlight local and template variables and promote val-centric, expression-based practices.
Explore the Scala for expression as a versatile control structure that iterates over any container—from ranges to options and futures—with generators and yield behavior.
Learn idiomatic Scala for-comprehensions with yield, returning a collection of results rather than side effects. See how range and vector use map and flatMap to produce a flat sequence.
Explain the four blocks of a Scala for comprehension—the four block and the yield block—covering generators, guards, and inline assignments, and show how they compile to maps and flat maps.
Learn how the for expression in Scala is not just looping, but a powerful tool for composing futures, options, and Try, enabling asynchronous, non-blocking code with yield.
Explore for expressions and match expressions in Scala, learning pattern matching, return types, and how they differ from switch, including case, underscore, and no fall through.
Explores match guards in Scala: use guards in pattern matches to filter cases like zero, positive, or negative values; demonstrates case v if v > 0 and a fallback.
Explore advanced pattern matching in scala by handling various kinds of data, including any type, strings, and lists, using case statements and a default case to prevent exceptions.
Explore string interpolation in Scala, using s-interpolator for values and expressions in braces, f-interpolator for formatted numeric output, and raw or triple-quoted strings with stripMargin for multi-line literals.
Practice module four exercises in Scala applied by running tests in IntelliJ, writing code to pass, and trying first before consulting solutions; then module five on functions and function literals.
Examine private and nested methods and master function literals, higher-order and first-order functions in Scala. Learn placeholder syntax, underscores, partial application, closures, partial functions, varargs, and named or default parameters.
Explore how nested method scoping in Scala allows inner methods to reuse outer variables, removing redundant parameters, and how deep nesting is possible yet should be used sparingly.
Discover function literals in Scala, aka lambdas, and their interchangeable use with methods. Learn converting a method to a function literal with the rocket operator and the int-to-int function type.
Explore function literals in Scala, using anonymous and named lambdas, and apply them with map to compute squares and boolean predicates, while understanding type inference and higher-order functions.
Explore how Scala function literals form Function2 objects and call apply, distinguishing function values from literals as lambdas improve efficiency since Java eight and Scala 212.
Scala generates extra methods on functions, including curried and tupled. Currying yields single-argument functions, while tupled accepts a tuple, enabling later use and turning it into a case class.
Explore higher order functions by examining map, filter, span, and partition, which take or return functions. Learn how predicates and function literals produce booleans and how first order functions differ.
Explore closures as a subset of function literals and see how they enclose external state, and learn to avoid mutable state that breaks referential transparency.
Explore partial functions in Scala, showing how curly brace case blocks define them, their relation to function one, and using them in pattern matching and maps.
Learn how partial functions are not required to cover all inputs and how isDefinedAt identifies defined cases, avoiding match errors by skipping undefined values with collect.
Demonstrates how map may be unsafe with a partial function, while collect, match with cases, and try catch define a partial function that both specifies inputs and restricts validity.
Explore var args in Scala Applied, declaring a final parameter as string star to accept zero or more names, received as an array behind the scenes.
Learn how var args complicate calling methods, and use the expansion operator, colon underscore star, to pass a list as var args, especially in recursion.
Explore named and default parameters in Scala, using parameter names for readability and calling by name in any order. See examples with force calculations and tail-recursive factorials using defaults.
Explore how higher order functions in Scala simplify code, enable resource management via the loan pattern, and use currying, arity, and by-name functions to craft a native-feeling loop.
Explore reading the first line of a file in Scala, with two functions: check for a question and convert the line to uppercase, using safe resource handling.
Explore generics and higher order functions in Scala by building a function with a generic type parameter A, reading first line and applying a string-to-A mapper with a default value.
Call the generic method with file contents using placeholder syntax to create variants, then group by character to identify the most common letter in Hamlet.
Explore the loan pattern in Scala by currying a generic loan to manage a resource, separating file handling from the operation, and enabling clean up with first-class functions.
After taking Scala Applied part 1, you will be able to:
Use the REPL (the Scala Interactive Shell) for experimentation and fun
Understand the basics of Scala syntax, including val, var, def, if, while, try, for and more
Create classes, objects and instances
Define and use function literals and higher order functions
Understand the basics of Scala's type inference and how to use it
Write custom control structures to augment those built into the language
Start down the path of a more functional style of programming
Be ready for Part 2 of Stairway to Scala Applied, which will dig into some of the differences between Scala and other languages
The course is half theory, half practice with hands on coding exercises built around test driven development examples. If you complete all three parts, with all the exercises, you will find that in addition to a strong grounding in the language theory, you will have the practical skills and comfort to code in Scala, as well as having the tools necessary to do so.
Unlike many other courses that teach a specific aspect of the Scala language, for example reactive programming or functional concepts, Stairway to Scala Applied provides a balanced and thorough introduction to the whole language and its concepts, including libraries like Actors and Collections. It is intended to accelerate your Scala learning curve and make you able to use Scala productively by the end of the course.
The course is taught by two highly experienced Scala developers who use Scala on a daily basis for real world commercial projects, and have done so for several years each.
Most of the lectures are practical demonstrations accompanied by a slide. You can download the slide deck and follow along on your computer, but the lectures are also presented using Udemy mashups, so the slide and practical demo can be switched between at will. If you hear typing, it's best to bring up the practical demo screencast instead of the slide in order to follow along.