Assigning empty string or string with letters results in GroovyCastException.Assigning a string with number values results in a number.What operation is happening here?
int var_1 = 2;
println var_1 // 2
var_1 = ""
println var_1 // GroovyCastException
int var_1 = 2;
println var_1 // 2
var_1 = "2"
println var_1 // 50
What operation/s results in 50?
It’s considering “2” as a single character string, and assigning that character’s Unicode value (U+0032 = ‘2’) to the variable. So for example, I suspect if you do this:
you’ll see 65 on the console