If I use var charSet = 1..10 it works, but when I am using the below code, I'm getting this error.
var charSet = "A".."Z"
for (value in charSet) {
println("$value")
}
For-loop range must have an 'iterator()' method.
Please let me know how to resolve this.
charSet is a ClosedRange<String> and that type doesn't have iterator() function (but ex. IntRange does). You can either change your range to 'A'..'Z' or create an extension function ClosedRange<String>.iterator() which would return a Iterator. The error should then go away
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With