This does not look very consistent to me. I think it could be useful to define (({false.to_i})) as 0 and (({true.to_i})) as 1. I think those are fairly common numeric values for False and True. These values as strings "0" and "1" are also commonly used in HTML forms to represent boolean values.
=end

This does not look very consistent to me. I think it could be useful to
define (({false.to_i})) as 0 and (({true.to_i})) as 1. I think those are
fairly common numeric values for False and True. These values as strings
"0" and "1" are also commonly used in HTML forms to represent boolean
values.
=end

Well, yes: ruby is not C and false is not 0. But why false could not be
converted to 0 by #to_i ?

That seems to imply that the reverse should hold, but (({!!0 => true})).

I do not think there is a rule that such fuzzy typecasting in Ruby has to be invertible:

"".to_i.to_s # => "0"

!!x is not one of Ruby type casting methods. If Ruby had a function Boolean(x), it would be natural to define it as !!x, but each class would need to define its own typecasting method. In my opinion, 0.to_b would have to be false.

Similarly, why should true.to_i return 1, and not -1 (as in Visual Basic) or 43 or 0 (which is also a truthy value)?

1 is simpler than 43 or -1. This is the usual convention of boolean algebra that 0 is false and 1 is true. The logical AND becomes simply the multiplication (mod 2). If it is false that you have some object, you have 0 of it. :)

This does not look very consistent to me. I think it could be useful to define (({false.to_i})) as 0 and (({true.to_i})) as 1. I think those are fairly common numeric values for False and True. These values as strings "0" and "1" are also commonly used in HTML forms to represent boolean values.
=end

Actually I am wondering the opposite, why nil.to_i is possible? It does
not make any sense to me.

I mean, my suggestion can cause problems if one uses true, false, nil for ternary logic, because nil.to_i and false.to_i would be both 0. According to Wikipedia, in ternary logic context, it is common to represent false by -1.