I am trying to do a very simple piece of code in Swift playgrounds.
var word = "Zebra"
for i in word {
  print(i)
}
However, I always get an error on line 3.
'String' does not have a member named 'Generator'
Any ideas on why this doesn't work? Note: I am working in Xcode 7, with Swift 2.0 (Strings and Characters).
                        
As of Swift 2,
Stringdoesn't conform toSequenceType. However, you can use thecharactersproperty onString.charactersreturns aString.CharacterViewwhich conforms toSequenceTypeand so can be iterated through with aforloop:Alternatively, you could add an extension to
Stringto make it conform toSequenceType:Although, I'm sure Apple had a reason for removing
String's conformance toSequenceTypeand so the first option seems like the better choice. It's interesting to explore what's possible though.