I'm trying to loop through a string and count its characters in Swift. This code successfully outputs the character count, but I receive this warning:
warning: immutable value 'character' was never used; consider replacing with '_' or removing it for character in quote { ^~~~~~~~~ _
This is my code:
var quote = "hello there"
var count = 0
for character in quote {
count = count + 1
}
print("\(count)")
Does anyone know why I have this warning? Also, is this the best way to approach this task? Thanks.