Define when class is truthy/falsy in ruby -
this question has answer here:
- how create object act false in ruby 2 answers
i want define when class truthy/falsy. possible?
class customnullobject def nil? true end end
example usage:
puts customnullobject.new ? 'ignore me' : 'print me! nullobject falsy'
it seems new
method customnullobject
should return true of false.
Comments
Post a Comment