Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created July 17, 2013 16:30
Show Gist options
  • Select an option

  • Save v6ak/6022187 to your computer and use it in GitHub Desktop.

Select an option

Save v6ak/6022187 to your computer and use it in GitHub Desktop.
type ICalculatingStrategy = (Int, Int)=>Int
val AdderStrategy: ICalculatingStrategy = (_+_)
val MultiplierStrategy: ICalculatingStrategy = (_*_)
val CalculatingOperations = Map(
"add" -> AdderStrategy,
"multiply" -> MultiplierStrategy
)
CalculatingOperations("multiply")(3, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment