Skip to content

Commit 5f5112a

Browse files
committed
py.None: eq and ne
1 parent 54f7fe1 commit 5f5112a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎py/none.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,28 @@ func (a NoneType) M__str__() Object{
2626
// Check interface is satisfied
2727
var_I__bool__=None
2828
var_I__str__=None
29+
30+
// Convert an Object to an NoneType
31+
//
32+
// Retrurns ok as to whether the conversion worked or not
33+
funcconvertToNoneType(otherObject) (NoneType, bool){
34+
switchb:=other.(type){
35+
caseNoneType:
36+
returnb, true
37+
}
38+
returnNone, false
39+
}
40+
41+
func (aNoneType) M__eq__(otherObject) Object{
42+
if_, ok:=convertToNoneType(other); ok{
43+
returnTrue
44+
}
45+
returnFalse
46+
}
47+
48+
func (aNoneType) M__ne__(otherObject) Object{
49+
if_, ok:=convertToNoneType(other); ok{
50+
returnFalse
51+
}
52+
returnTrue
53+
}

0 commit comments

Comments
(0)