4 ms·
Many languages propose a system of ranges: case 'a' .. 'z', 'A' .. 'Z', '0' .. '9', '_': ...; although when working with enumerators, there is a still a r
by sixthDot 1y ago
Many languages propose a system of ranges:
case 'a' .. 'z', 'A' .. 'Z', '0' .. '9', '_': ...;
although when working with enumerators, there is a still a risk caused by the fact that re-ordering enumerators or adding new ones can break the switches.
Despite of the drawback I prefer. Also a Range can be a formal expression which simplifies the grammar of other sub-expressions and statements, not only switches but also array slices, tuple slices, foreach, literal bitsets, etc.
- lerno 1y agoC3 has case ranges, like case 'a'..'z': It's from the GCC C extension (except GCC uses ...)