A random collection of useful vim commands, hints and features.
%- represents the current file- %:h is a modifier for the current file directory
| package net.martinprobson.scala.Extractors | |
| trait User | |
| class StandardUser(val firstName: String, val lastName:String) extends User | |
| object StandardUser { | |
| def unapply(s: StandardUser): Option[(String, String)] = Some((s.firstName,s.lastName)) | |
| } |
| import com.google.inject.{AbstractModule,Guice,Inject,ImplementedBy} | |
| /* | |
| This example shows how just in time (JIT) DI injection works in Google guice. | |
| */ | |
| object Main extends App { | |
| // | |
| // First, let us create an injector with a specific binding. | |
| // |
Referential Transparency and Purity
An expression e is referentially transparent if, for all programs p, all occurrences of e in p can be replaced by the result of
Very simple example showing how implicit conversions work in Scala.
Let's try converting a StringBuffer into a List of characters.
Note We are using StringBuffer here instead of String because implicit conversion from String to List
is already supported as standard in the Scala PreDef object. If we used String it would break rule 3 below.