examples: use is_letter() method

pull/2490/head
Robin Martijn 2019-10-22 07:00:28 +02:00 committed by Alexander Medvednikov
parent fdfa564865
commit 03cd34fb54
1 changed files with 2 additions and 8 deletions

View File

@ -61,19 +61,13 @@ fn filter_word(word string) string {
return '' return ''
} }
mut i := 0 mut i := 0
for i < word.len && !is_letter(word[i]) { for i < word.len && !word[i].is_letter() {
i++ i++
} }
start := i start := i
for i < word.len && is_letter(word[i]) { for i < word.len && word[i].is_letter() {
i++ i++
} }
end := i end := i
return word.substr(start, end) return word.substr(start, end)
} }
// TODO remove once it's possible to call word[i].is_letter()
fn is_letter(c byte) bool {
return c.is_letter()
}