I am very new to Scala and don't know how to swap out vars and use vals into the code. There are lots of vars in the code.
Below is just a piece of code:
var fa = new JsArray
val ra = Json.obj("key1" -> val1, "key2" -> val2, "key3" -> val3)
fa = fa.:+(ra)
How to use val for fa ?
2nd Case:
val a = 10
var dr: String = ""
if (a == 10) {
dr = "true"
}
else {
dr = "false"
}
println("dr: " + dr)
Here, if I put val for "dr" inside if/else then it cannot be access in println(). Is there anything help on it to avoid var ?