case branches support constant sets for convenience
This commit is contained in:
parent
54021471e4
commit
8b6f9ef5e8
5 changed files with 92 additions and 17 deletions
15
tests/accept/run/tcase_setconstr.nim
Normal file
15
tests/accept/run/tcase_setconstr.nim
Normal 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")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue