Skip to content

Instantly share code, notes, and snippets.

@LenKIM
Last active July 20, 2019 07:50
Show Gist options
  • Save LenKIM/5dae8bfc09673a81518391082687968b to your computer and use it in GitHub Desktop.
Save LenKIM/5dae8bfc09673a81518391082687968b to your computer and use it in GitHub Desktop.
부분적용.scala
object 부분적용 {
def price(product: String): Double =
product match {
case "apples" => 140
case "oranges" => 223
}
def withTax(cost: Double, state: String): Double =
state match {
case "NY" => cost * 2
case "FL" => cost * 3
}
val locallyTaxed: Double => Double = withTax(_: Double, "NY")
val costOfApples: Double = locallyTaxed(price("apples"))
println(costOfApples)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment