我想定义我的类什么时候是真的/假的。有可能吗?
class CustomNullObject
def nil?
true
end
end示例用法:
puts CustomNullObject.new ? 'ignore me' : 'PRINT ME! NullObject is falsy'发布于 2015-08-31 16:23:56
CustomNullObject的new方法似乎应该返回true或false。
https://stackoverflow.com/questions/32306825
复制相似问题