case branches support constant sets for convenience

This commit is contained in:
Araq 2011-06-19 17:45:33 +02:00
commit 8b6f9ef5e8
5 changed files with 92 additions and 17 deletions

View file

@ -0,0 +1,15 @@
discard """
output: "an identifier"
"""
const
SymChars: set[char] = {'a'..'z', 'A'..'Z', '\x80'..'\xFF'}
proc classify(s: string) =
case s[0]
of SymChars, '_': echo "an identifier"
of {'0'..'9'}: echo "a number"
else: echo "other"
classify("Hurra")