Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
To Lower Case
class Solution {
func toLowerCase(_ s: String) -> String {
var result = ""
for c in s {
var letter = c
if c >= "A", c <= "Z" {
letter = toLower(c)
}
result += "\(letter)"
}
return result
}
func toLower(_ character:Character) -> Character {
let asciiValue:UInt8 = character.asciiValue! + 32
return Character(UnicodeScalar(asciiValue))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment