const AlphaNum: set[char] = {'a' .. 'z', 'A' .. 'Z', '0' .. '9'} MathOp = {'+', '-', '*', '/'} # set[char] ANMO = AlphaNum + MathOp # union var x: char = 's' echo x in AlphaNum echo x in MathOp type CharRange = set['a' .. 'f'] # var y: CharRange = {'x'} #invalid var y: CharRange = {'b', 'd'} echo 'c' in y type ChessPos = set[0'i8 .. 63'i8] var baseLine: ChessPos = {1.int8} var p: int8 echo p in baseLine type H = set[0 .. 63] var h: H = H({1}) echo typeof({1}) echo typeof({-1}) echo typeof({1'i8}) Run
Sets of char are easy. But sets of numbers are more difficult. The operations with the ChessPos type are OK. But with type H = set[0 .. 63] var h: H = H({1}) I do not get the assignment to var h working. Nothing of following code seems to compile: var h: H = {1} var h: H = H({1}) var h: H = {1'i8} var h: H = {1'} And echo typeof({-1}) is set[range 0..65535(int)] which is also a bit strange.