I'm new to Scala but I've been working with Java for a long time now so programming is not new to me. Anyway I read a some books on Scala and came across an example that a method returns a function. Now returning a function from method is not new since Java 8 support lambda expression but I can't understand the following example:
def lowIt(inputValue: String): Double => Double = {
if (inputValue == "Lower") x => x * 0.85
else x => x
}
I don't understand where x comes from, I would expect the following:
def lowIt(inputValue: String): Double => Double = x => {
if (inputValue == "Lower") x * 0.85
else x
}
I don't get the first way of writing the above method. Thank u in advance