Skip to content

Commit db28072

Browse files
committed
py: dict: implement __eq__ and __ne__
1 parent b306413 commit db28072

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

py/dict.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,30 @@ func (d StringDict) M__setitem__(key, value Object) Object {
5757
d[string(str)] = value
5858
return None
5959
}
60+
61+
func (a StringDict) M__eq__(other Object) Object {
62+
b, ok := other.(StringDict)
63+
if !ok {
64+
return NotImplemented
65+
}
66+
if len(a) != len(b) {
67+
return False
68+
}
69+
for k, av := range a {
70+
bv, ok := b[k]
71+
if !ok {
72+
return False
73+
}
74+
if Eq(av, bv) == False {
75+
return False
76+
}
77+
}
78+
return True
79+
}
80+
81+
func (a StringDict) M__ne__(other Object) Object {
82+
if a.M__eq__(other) == True {
83+
return False
84+
}
85+
return True
86+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy