No more fall through in case statement?
bearophile
bearophileHUGS at lycos.com
Thu Jan 3 09:44:48 PST 2008
bearophile:
> caseof (s[i]) {
> case ' ': fall;
> case '\t': fall;
> case '\f': fall;
> case '\r': fall;
> case '\n': fall;
> case '\v':
> if (inword) {
> r ~= capitalize(s[istart .. i]);
> inword = false;
> }
>
> default:
> if (!inword) {
> if (r.length)
> r ~= ' ';
> istart = i;
> inword = true;
> }
> }
Let's try again, 2 keywords less:
caseof (s[i]) {
case ' ': continue;
case '\t': continue;
case '\f': continue;
case '\r': continue;
case '\n': continue;
case '\v':
if (inword) {
r ~= capitalize(s[istart .. i]);
inword = false;
}
else:
if (!inword) {
if (r.length)
r ~= ' ';
istart = i;
inword = true;
}
}
:-)
Bye,
bearophile
More information about the Digitalmars-d
mailing list