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# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -