v
v copied to clipboard
Dose for in not support string?
Dose for in not support string?
Sorry, I don't understand the question.
I think he means "can a for-loop iterate over the characters in a string?"
@zac-garby yes,like this: for char in string { ... }
Now you can:
fn main() {
s := 'hello'
for c in s {
println(c.str())
}
}
UTF-8 is not handled yet, but it will be like Go's range str soon.
I run your code,here is the error message:
for in requires an array but got string