I have written code to calculate some condition in old style. But is there any other way to write code using more functional programming.
def getAgeType(age: Int) =
age match {
case age:Int if (age <= 10) => println("This age belongs to kids")
case age:Int if (age > 10 && age <= 20) => println("This age belongs to teens")
case age:Int if (age > 20 && age <= 60) => println("This age belongs to adults")
case age:Int if (age > 60) => println("This age belongs to adults")
}
Can someone give me better code. Thanks in advance kanti