Letter ranges can be constructed by using the inclusive or exclusive range
operators. However, ranges from 'a'
to 'z
' (or '1'
to '9'
) constructed
with the exclusive range operator exclude the upper bound: 'z'
(or '9'
),
because such ranges are half open.
Ranges such as 'a'..'z'
are probably unintentional. Consider using the
inclusive range operator to include all the letters: 'a'..='z'
. If this is
intentional, make it clear by explicitly excluding the upper bound:
'a'..='y'
.
for letter in 'a'..'z' {
// ...
}
for letter in 'a'..='z' {
// ...
}