I am trying to do the following in as little code as possible and as functionally as possible:
def restrict(floor : Option[Double], cap : Option[Double], amt : D
I like the initial solution with the match-case most - beside the fact, that I didn't understand that amt
means amount
(in Germany, 'amt' means 'office') and I only knew cap
as something I wear on my head ...
Now here is a really uninspired solution, using an inner method:
def restrict(floor : Option[Double], cap : Option[Double], amt : Double) : Double = {
def restrict (floor: Double, cap: Double, amt: Double) =
(floor max amt) min cap
var f = floor.getOrElse (amt)
val c = cap.getOrElse (amt)
restrict (f, c, amt)
}