Skip to content

Commit 7e4f791

Browse files
committed
py: method - add __eq__ and __ne__
1 parent 40a2528 commit 7e4f791

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

py/method.go

+18
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,25 @@ func (m *Method) M__get__(instance, owner Object) (Object, error) {
172172
return m, nil
173173
}
174174

175+
// FIXME this should be the default?
176+
func (m *Method) M__eq__(other Object) (Object, error) {
177+
if otherMethod, ok := other.(*Method); ok && m == otherMethod {
178+
return True, nil
179+
}
180+
return False, nil
181+
}
182+
183+
// FIXME this should be the default?
184+
func (m *Method) M__ne__(other Object) (Object, error) {
185+
if otherMethod, ok := other.(*Method); ok && m == otherMethod {
186+
return False, nil
187+
}
188+
return True, nil
189+
}
190+
175191
// Make sure it satisfies the interface
176192
var _ Object = (*Method)(nil)
177193
var _ I__call__ = (*Method)(nil)
178194
var _ I__get__ = (*Method)(nil)
195+
var _ I__eq__ = (*Method)(nil)
196+
var _ I__ne__ = (*Method)(nil)

0 commit comments

Comments
 (0)