Files
pplus-library/mojo/probes/set-discard-dict-pop.mojo
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

27 lines
738 B
Mojo

# 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))