Make FalseClass behave like TrueClass with meta programming

Posted by Edvinas Bartkus on Stack Overflow See other posts from Stack Overflow or by Edvinas Bartkus
Published on 2010-05-05T09:14:26Z Indexed on 2010/05/05 9:18 UTC
Read the original article Hit count: 128

Filed under:

This is theoretical question: is it possible to change FalseClass behavior to act like TrueClass? It is possible to override to_s, xor, &, | behavior but that is not enough.

If you like Test Driven Development, follow my colleague's suggestion:

puts "false is new true!" if false
puts "never happens" if true

Asserts won't work, would it? Is it possible to pass the test successfully?

© Stack Overflow or respective owner

Related posts about ruby