Skip to content

Instantly share code, notes, and snippets.

@purefn
Created July 30, 2011 00:14
Show Gist options
  • Save purefn/1115012 to your computer and use it in GitHub Desktop.
Save purefn/1115012 to your computer and use it in GitHub Desktop.
Introduction to Scala - outline
* What is Scala?
** OO
*** example class
** Functional (sorta)
*** example map and foldLeft
* Some basics
** Defining values/variables
*** examples with/without type inference
** Defining functions
*** examples with/without return value
** Basic control structures
*** while and foreach (imperative, don't use unless you really have to)
*** try-catch-finally
*** if expressions - yup, it's an expression, it has a value
*** for-comprehensions - ya, they're values too
** Data types
*** Primitives
**** Byte, Short, Int, Long Char, String, Float, Double, Boolean
*** Arrays
*** Lists
*** Tuples
*** Sets
*** Maps
** There are no operators
*** just methods
*** unary_-
*** standard ops, standard precendence and associativity, but == is .equals in Java
*** special cases
**** operators ending in : are right associative - example a ::: b = b.:::(a)
** Packages
*** saner than Java's
*** package objects
** Imports
*** Aliasing!
** Access modifiers
*** same as Java's, with extra goodness
** Classes
*** start with class with var
*** add a method or 2
**** methods can have parameters or not
**** def width() is different than def width
*** Ctors - primary and aux
*** extending classes
**** calling super classes ctor
**** annotating with override
** Objects
*** object key word
*** companion objects
**** apply() as factory
** traits - a mix of interfaces and abstract classes, but better
*** stackable
**** linearize right to left
**** avoids multi-inheritance diamond
* Type aliases
* Self types
* Pattern matching
** match statement
** partial functions
** when assigning values
** in for-expressions
** Extractors
* Case classes
* Sealing classes/traits
* Functions/Lambas
** types
** literals
*** example with full types
*** example with inferred type
*** example with placeholder with
*** example with multiple placeholders
** partially applied functions (println _)
** using contextual values
*** def mkInc(amount: Int) = (x:Int) => x + amount
** curried version
*** def mkInc(amount: Int)(x: Int) = x + amount
** By-name parameters
*** def log(message: => String)
* Implicit conversions
** Pimp my library
* Type context/bounds
* Implicit parameters
** type classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment