add sets.pop procedure (analogue to python) (#8383)

This commit is contained in:
skilchen 2018-07-21 19:51:14 +02:00 • committed by Andreas Rumpf
commit 8fe8bed9c3
2 changed files with 34 additions and 0 deletions

22
tests/sets/tsetpop.nim Normal file
View file

@ -0,0 +1,22 @@
discard """
targets: "c c++ js"
output: '''1000
0
set is empty
'''
"""
import sets
var a = initSet[int]()
for i in 1..1000:
a.incl(i)
echo len(a)
for i in 1..1000:
discard a.pop()
echo len(a)
try:
echo a.pop()
except KeyError as e:
echo e.msg