Details
Description
Try it out:
println "0" as int
println "0".asType(int.class)
I get this output:
0
48
This happens for all the primitives: byte, short, int, long, float, double
Using the non-primitive types yields the correct result, i.e.:
println "0" as Integer
println "0".asType(Integer.class)
gives:
0
0
Just wanted to confirm, if all 4 cases below are expected to produce "0" as the output:
Or, does anyone defend the output of the last case where it is producing "48" as the output?
I ask because DefaultTypeTransformation#castToNumber(Object, Class) tries to do return the ascii value of the first character of the string passed - Integer.valueOf(c.charAt(0)).
So the confusion is whether "48" is incorrect or "0"?