erg/crates/erg_compiler/lib/std.d/Dict!.d.er
2023-10-05 00:57:08 +09:00

32 lines
824 B
Python

# TODO: transition specifications
dict = pyimport "Dict"
.Dict!: ClassType
.Dict! <: dict.Dict
.Dict!.
'''erg
dic = !{"a": 1}
dic.insert!("b", 2)
assert dic == {"a": 1, "b": 2}
'''
insert!: |K, V|(self: .Dict!(K, V), key: K, value: V) => NoneType
'''erg
dic = !{"a": 1}
x = dic.remove!("a")
assert dic == {}
assert x == 1
'''
remove!: |K, V|(self: .Dict!(K, V), key: K) => V or NoneType
'''erg
dic = !{"a": 1}
dic.update!({"b": 2})
dic.update!([("c", 3)])
assert dic == {"a": 1, "b": 2, "c": 3}
'''
update!: |K, V|(self: .Dict!(K, V), other: Iterable([K, V])) => NoneType
'''erg
dic = !{"a": 1}
dic.merge!({"b": 2})
assert dic == {"a": 1, "b": 2}
'''
merge!: |K, V|(self: .Dict!(K, V), other: .Dict!(K, V)) => NoneType