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

c# - ajax - How to receive data both html and json from server? -

c# - SharpDX Toolkit models rendering inside out -