Hello there, let start with the obligatory code block:
1 var myString:String="15";
2 var secondDigit=myString[1];
3 print("the second digit of my String is "+secondDigit);
4 var secondDigitAsInt=parseInt(myString[1]);
5 print("10="+(5+secondDigitAsInt));
I have a string, take the second digit only. It works fine to concatenate to a string as in like 3, but if I want to use it as an integer via parseInt(), I get a 53 as a result. This was driving me nuts for hours because I didn’t have a clue where that 53 was coming from until it dawned on me: 53 is the ASCII code for “5”.
After a while of rolling on the floor, facepalming i’m back in the ranks of the sane people and would like to ask: is there a way to convert this char or whatever it is back to an integer i can calculate with the right way?