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

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

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