Skip to content

Instantly share code, notes, and snippets.

View mmollaverdi's full-sized avatar

Mehdi Mollaverdi mmollaverdi

  • Melbourne
View GitHub Profile
@kciesielski
kciesielski / FunctionalDecorator.scala
Created November 22, 2012 20:49
Functional decorator
object Rebates {
type RebatePolicy = (Product, Int, Money) => Money
}
object standardRebate extends ((Double, Int) => RebatePolicy) {
def apply(rebate: Double, minimalQuantity: Int) = {
(product, quantity, regularCost) => {
val rebateRatio = BigDecimal(rebate / 100)
if (quantity >= minimalQuantity)