This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,26 @@
|
||||
# probe: Set.discard of a member and of a missing one; Dict.pop with a default, on a present and a missing key, and without one on a missing key
|
||||
from std.collections import Set
|
||||
|
||||
|
||||
def main() raises:
|
||||
var s = Set[Int](3, 1)
|
||||
s.discard(7)
|
||||
s.discard(3)
|
||||
print(len(s), 1 in s, 3 in s)
|
||||
var m: Dict[String, Float64] = {"k": 1}
|
||||
var a = m.pop("zz", 0.0)
|
||||
var b = m.pop("k", 5.0)
|
||||
print(a, b, len(m))
|
||||
var g = Dict[Int, List[Int]]()
|
||||
g[2] = [1, 2]
|
||||
var x = g.pop(2, List[Int]())
|
||||
var y = g.pop(2, List[Int]())
|
||||
x.append(3)
|
||||
print(x, y, len(g))
|
||||
_ = m.pop("q", 0.0)
|
||||
var e: Dict[String, Int] = {"a": 1}
|
||||
try:
|
||||
_ = e.pop("q")
|
||||
except err:
|
||||
print("raised", err)
|
||||
print(len(e))
|
||||
Reference in new issue
Block a user