From: "Vít Ondruch" Date: 2013-02-28T14:23:24+09:00 Subject: [ruby-core:53027] Re: [ruby-trunk - Feature #7978][Open] boolean to_i Dne 27.2.2013 15:00, alexeymuranov (Alexey Muranov) napsal(a): > Issue #7978 has been reported by alexeymuranov (Alexey Muranov). > > ---------------------------------------- > Feature #7978: boolean to_i > https://bugs.ruby-lang.org/issues/7978 > > Author: alexeymuranov (Alexey Muranov) > Status: Open > Priority: Normal > Assignee: > 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 > > > Actually I am wondering the opposite, why nil.to_i is possible? It does not make any sense to me. V��t