Created
November 11, 2014 19:46
-
-
Save bbq2100/f2c16057e617e9bd687c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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