Skip to content

Instantly share code, notes, and snippets.

@bbq2100
Created November 11, 2014 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbq2100/f2c16057e617e9bd687c to your computer and use it in GitHub Desktop.
Save bbq2100/f2c16057e617e9bd687c to your computer and use it in GitHub Desktop.
trait TaxStrategy {
def tax(s: String): Double
}
class StrategyA extends TaxStrategy {
override def tax(s: String): Double = 1
}
class StrategyB extends TaxStrategy {
override def tax(s: String): Double = 2
}
def taxIt: TaxStrategy => String => Double = strategy => s => strategy.tax(s)
taxIt(new StrategyA)("ASDF")
taxIt(new StrategyB)("ASDF")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment