Last active
July 20, 2019 07:50
-
-
Save LenKIM/5dae8bfc09673a81518391082687968b to your computer and use it in GitHub Desktop.
부분적용.scala
This file contains hidden or 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
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