Clone wiki

ScalaKoansExercises / FindingYourPath

Each koan will provide guidance along your path to enlightenment. Here's what WE think you will learn.

Use ThisTo Meditate On...
AboutAssertsHow Scala koans work
AboutValAndVarHow val and var declarations differ
AboutLiteralsHow to specify values for the data types that resemble Java primitives
AboutLiteralBooleansHow to specify boolean values
AboutLiteralNumbersHow to specify values for the common numeric data types
AboutLiteralStringsHow to write literal values for character and string data
AboutConstructorsHow to provide parameters when constructing objects
How val and var parameters differ
How constructor parameters create private members
AboutTuplesHow to write a literal tuple value
How to access the values in a tuple
Whether all values in a tuple must have the same type
AboutListsHow Nil lists compare
How to write a literal list
How to access the values in a list
How to alter the contents of a list
Discovering some common List methods
Transforming, filtering, and summarizing lists
Quickly creating a list of consecutive integers
Sharing content between lists
AboutMapsHow to write a literal map
What happens if a key appears more than once
Iterating through the contents of a map
Whether all keys or values in a map must have the same type
How to access the values in a map
How to remove entries from a map
AboutSetsHow to write a literal set value
What happens if a value appears more than once
Whether all values in a set must have the same type
How to test for the presence of a value in a set
How to alter the content of a set
How to iterate through the values in a set
How to perform familiar operations on a set
AboutSequencesAndArraysHow to write a literal array value
How to convert between various kinds of sequences
How to transform and filter lists
AboutMutableMapsHow to create maps whose contents can be altered
How to add and remove map content
AboutMutableSetsHow to create sets whose contents can be altered
How to add and remove set content
AboutOptionsHow to avoid using raw nulls
How to safely deal with "missing" or optional data
How to operate on an optional value
How to work with a list of optional values
AboutPatternMatchingHow to use pattern matching to replace complex conditional logic
How to ignore part of the data being pattern matched
How to "capture" matched data for later use
How to use pattern matching to simplify working with regular expressions
How to refer to the contents of existing variables when pattern matching
AboutCaseClassesHow to use case classes to write less boilerplate
Discovering which methods are automatically provided with case classes
How to create a mutable case class
How to avoid using a mutable case class
How to use named parameters to simplify working with case classes even further
How to "deconstruct"" an instance of a case class
AboutHigherOrderFunctionsHow to write and use anonymous functions
How a closure differs from a "pure" function
How to return a function as a result
How to compose new functions from existing ones
How to use currying to "specialize" functions
How to create a function from a class method
AboutPartiallyAppliedFunctionsHow to create a function by specifying only some of the arguments to another function
AboutPartialFunctionsHow to safely create functions that are only defined for subsets of their arguments
How to easily combine these partial functions to create new functions