I have an Object
object Constants {
val getA = "example.a.test"
val getB = "example.b.test"
val getC = "example.c.test"
.
.
.
}
I have another class where I'm accessing these values after importing the class in an if-else loop
if(str == "A") {
println(Constants.getA)
}
else if (str == "B") {
println(Constants.getB)
} else {
println(Constants.getC)
}
// and so on...
NOTE: This is just a sample code I have but the if-else loops get complicated. Is there a way to simplify this by passing the "str" variable directly to the object like "Constants.get$str" or something simpler? I get Cyclomatic complexity Scala check style warning
Constantscan't be aMap[K,V], i.e.Map("A" -> "example.a.test")?