Ai
3 Star 0 Fork 0

mirrors_go-python/gpython

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
none.go 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
// None objects
package py
type NoneType struct{}
var (
NoneTypeType = NewType("NoneType", "")
// And the ubiquitous
None = NoneType(struct{}{})
)
// Type of this object
func (s NoneType) Type() *Type {
return NoneTypeType
}
func (a NoneType) M__bool__() (Object, error) {
return False, nil
}
func (a NoneType) M__str__() (Object, error) {
return a.M__repr__()
}
func (a NoneType) M__repr__() (Object, error) {
return String("None"), nil
}
// Convert an Object to an NoneType
//
// Retrurns ok as to whether the conversion worked or not
func convertToNoneType(other Object) (NoneType, bool) {
switch b := other.(type) {
case NoneType:
return b, true
}
return None, false
}
func (a NoneType) M__eq__(other Object) (Object, error) {
if _, ok := convertToNoneType(other); ok {
return True, nil
}
return False, nil
}
func (a NoneType) M__ne__(other Object) (Object, error) {
if _, ok := convertToNoneType(other); ok {
return False, nil
}
return True, nil
}
// Check interface is satisfied
var _ I__bool__ = None
var _ I__str__ = None
var _ I__repr__ = None
var _ I__eq__ = None
var _ I__ne__ = None
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_go-python/gpython.git
git@gitee.com:mirrors_go-python/gpython.git
mirrors_go-python
gpython
gpython
v0.0.1

搜索帮助