add setutils.[]= (#17272)

* add setutils.[]=
* address comments
* proc => func (for other symbols too)
This commit is contained in:
Timothee Cour 2021-03-08 01:39:39 -08:00 • committed by GitHub
commit 93cb5d6896
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 4 deletions

View file

@ -32,5 +32,16 @@ template main =
doAssert {range[0..10](0), 1, 2, 3}.complement == {range[0..10](4), 5, 6, 7, 8, 9, 10}
doAssert {'0'..'9'}.complement == {0.char..255.char} - {'0'..'9'}
block: # `[]=`
type A = enum
a0, a1, a2, a3
var s = {a0, a3}
s[a0] = false
s[a1] = false
doAssert s == {a3}
s[a2] = true
s[a3] = true
doAssert s == {a2, a3}
main()
static: main()