I have these two functions:
def replaceValue(value: String): String =
if (value.startsWith(":")) value.replaceFirst(":", "/") else value
def getData(value: String): String = {
val res = replaceValue(value).replace("-", ":")
val res1 = res.lastIndexOf(":")
if (res1 != -1) res.substring(0,3)
else res.concat("-")
}
I want to convert them to higher order functions.
I have tried this so far. What would be the higher order function for it?
def getData = (value: String) => {
val res = replaceValue(value).replace("-", ":")
val res1 = res.lastIndexOf(":")
if (res1 != -1) res.substring(0,3)
else res.concat("-")
}
getData
function? – Tomer Shetah