I want to return the first letter of a String
as a String
instead of as a Character
:
func firstLetter() -> String {
return self.title[0]
}
However, with the above I get Character is not convertible to String
. What's the right way to convert a Character to a String?
This answer suggests creating a subscript extension, but the declaration for String
already has a subscript method:
subscript (i: String.Index) -> Character { get }
Is that answer outdated, or are these two different things?