I have the below function in scala:
def addAllCosts(costs: List[Int],discount: Int => Int): Int = {
var sum = 0
costs.foreach(sum += _)
discount(sum)
}
I am invoking the function like so in a http akka router:
HttpResponse(200, entity= repository.addAllCosts(costs,repository.applyDiscount(23)))
applyDiscount looks like this:
def applyDiscount(sum:Int): Int = {
return sum - discount
}
However, I am getting the following error:
Error:(45, 94) type mismatch;
found : Int
required: Int => Int
Not sure how to resolve this? Thanks!