From: "alexeymuranov (Alexey Muranov)" Date: 2013-02-28T05:11:00+09:00 Subject: [ruby-core:53008] [ruby-trunk - Feature #7978] boolean to_i Issue #7978 has been updated by alexeymuranov (Alexey Muranov). matz (Yukihiro Matsumoto) wrote: > Ruby is not C. 0 is not false. false is not 0. In some respects they are similar, and 0 and 1 are often used in relation to logical operation. For example, the characteristic function of a set P is defined as ��_P(x) = 1 if x���P is true ��_P(x) = 0 if x���P is false The simplest boolean algebra consists of 0 and 1 with the usual algebraic operations mod 2. ---------------------------------------- Feature #7978: boolean to_i https://bugs.ruby-lang.org/issues/7978#change-37163 Author: alexeymuranov (Alexey Muranov) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =begin The current behavior is the following: > nil.to_i => 0 > false.to_i NoMethodError: undefined method `to_i' for false:FalseClass > true.to_i NoMethodError: undefined method `to_i' for true:TrueClass 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 -- http://bugs.ruby-lang.org/