I want to convert a char to an int value.
I am a bit puzzled by the way toInt works.
println(("123").toList) //List(1, 2, 3)
("123").toList.head // res0: Char = 1
("123").toList.head.toInt // res1: Int = 49 WTF??????
49 pops up randomly for no reason.
How do you convert a char to int the right way?
Use Integer.parseInt(“1”, 10). Note that the 10 here is the radix.
49 does not pop up randomly. It’s the ascii representation of “1”. See http://www.asciitable.com/