Define when class is truthy/falsy in ruby -


this question has answer here:

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

Popular posts from this blog

renaming files in a directory using python or R -

html - outline-style different in chrome compared to firefox and internet explorer -

ruby on rails - Carrierwave Timeout -