On Oct 27, 9:18 am, Dave River <carlos_la... / yahoo.com.hk> wrote:
> 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.

There are not any ways to do so in Ruby. Sorry. (This question comes
up every few weeks or so.)