The Strategy
interface is first-class (=> Unit
).
class Context(e: => Unit) { def exec = e } val strategyA = new Context(println("strategyA")) val strategyB = new Context(println("strategyB")) def main(args: Array[String]) { strategyA.exec strategyB.exec }
Wrap the value with new Context
then later unwrap the value with exec
ߞ for what
gain?