> Thus 'if x.ok?' returns the same as 'if x' for any object, but @ok for
> yours!


Thanks for your explanation!

In fact, I am making a wrapper class called Boolean which cooperates 
with some legacy code in my company because there are some compatibility 
problems between different languages.

I write some code like the following and the Boolean object hides some 
underlying code which solve the compatibility problems.
x = Boolean.new()
if x
   do something....
end

If ruby does not support something like __bool__ in Python, I need to 
write some code in the following way.
x = Boolean.new()
if x.evaluate()
   do something...
end

But I would prefer "if x " instead of "if x.evaluate" because it is more 
straight forward. So, I would like to know whether there are any ways to 
do so.

Regards,
Dave
-- 
Posted via http://www.ruby-forum.com/.