From: "Юрий Соколов" Date: 2013-02-28T05:56:31+09:00 Subject: [ruby-core:53009] Re: [ruby-trunk - Feature #7978][Rejected] boolean to_i --f46d0421a64faded1904d6baeaf0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Well, yes: ruby is not C and false is not 0. But why false could not be converted to 0 by #to_i ? 27.02.2013 23:07 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 "matz (Yukihiro Matsu= moto)" < matz@ruby-lang.org> =CE=C1=D0=C9=D3=C1=CC: > > > Issue #7978 has been updated by matz (Yukihiro Matsumoto). > > Status changed from Open to Rejected > Assignee set to matz (Yukihiro Matsumoto) > > Ruby is not C. 0 is not false. false is not 0. > nil has its role as a default value, true/false are not. > > Matz. > > ---------------------------------------- > Feature #7978: boolean to_i > https://bugs.ruby-lang.org/issues/7978#change-37162 > > Author: alexeymuranov (Alexey Muranov) > Status: Rejected > Priority: Normal > Assignee: matz (Yukihiro Matsumoto) > Category: core > Target version: next minor > > > =3Dbegin > The current behavior is the following: > > > nil.to_i > =3D> 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. > =3Dend > > > > -- > http://bugs.ruby-lang.org/ > --f46d0421a64faded1904d6baeaf0 Content-Type: text/html; charset=KOI8-R Content-Transfer-Encoding: quoted-printable

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

27.02.2013 23:07 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 "= matz (Yukihiro Matsumoto)" <m= atz@ruby-lang.org> =CE=C1=D0=C9=D3=C1=CC:
>
>
> Issue #7978 has been updated by matz (Yukihiro Matsumoto).
>
> Status changed from Open to Rejected
> Assignee set to matz (Yukihiro Matsumoto)
>
> Ruby is not C. 0 is not false. false is not 0.
> nil has its role as a default value, true/false are not.
>
> Matz.
>
> ----------------------------------------
> Feature #7978: boolean to_i
> https:= //bugs.ruby-lang.org/issues/7978#change-37162
>
> Author: alexeymuranov (Alexey Muranov)
> Status: Rejected
> Priority: Normal
> Assignee: matz (Yukihiro Matsumoto)
> Category: core
> Target version: next minor
>
>
> =3Dbegin
> The current behavior is the following:
>
> =9A > nil.to_i
> =9A =9A=3D> 0
> =9A > false.to_i
> =9A NoMethodError: undefined method `to_i' for false:FalseClass >
> =9A > true.to_i
> =9A NoMethodError: undefined method `to_i' for true:TrueClass
>
> This does not look very consistent to me. =9AI think it could be usefu= l to define (({false.to_i})) as 0 and (({true.to_i})) as 1. =9AI think thos= e are fairly common numeric values for False and True. =9AThese values as s= trings "0" and "1" are also commonly used in HTML forms= to represent boolean values.
> =3Dend
>
>
>
> --
> http://bugs.ruby-lang.org/<= br> >

--f46d0421a64faded1904d6baeaf0--