So I have a String
of integers that looks like "82389235"
, but I wanted to iterate through it to add each number individually to a MutableList
. However, when I go about it the way I think it would be handled:
var text = "82389235"
for (num in text) numbers.add(num.toInt())
这会将与字符串完全无关的数字添加到列表中.然而,如果我使用println
将其输出到控制台,那么它可以很好地遍历字符串.
如何正确地将Char
转换为Int
?