From: "José Francisco Calvo Moreno" Date: 2011-11-15T01:54:59+09:00 Subject: [ruby-core:41031] Re: Proposal to add new methods: positive? negative? natural? --0015175df1620fc6c904b1b4bbea Content-Type: text/plain; charset=ISO-8859-1 Hi Jeremy, I really think that number.positive? is more readable than number > 0 I think that using the positive? method condition is much more clear. On the other hand I think that is not necessary to add nonpositive? and nonnegative? you could use not number.positive? or not number.negative? About to add this method to Fixnum, Integer or Numeric you must excuse me because I'm starting to understand the Ruby Core. I though that Fixnum is the base of Integer number and adding a C function to it will solve the problem and make the condition faster. About the zero condition, I have my doubts but maybe a solution would be return nil. Regards. 2011/11/14 Jeremy Evans > > On 11/15 12:58, Jos? Francisco Calvo Moreno wrote: > > Hi all! > > > > In order to increase Ruby code readability I have met many times with > > the need to add the following methods to Fixnum: > > > > #positive? (return true if number > 0, return false if number < 0) > > #negative? (return true if number < 0, return false if number > 0) > > Is > > number.positive? > > really more readable than > > number > 0 > > I personally think the > operator is more readable, so I would be > against including this in core. Plus, your description of the methods > does not describe the behavior of the case where number == 0 (though I > can guess the desired behavior). By your reasoning, we would also have > to add nonpositive? and nonnegative? for <= 0 and >= 0. > > If you were going to add it, why would you want to add this just to > Fixnum instead of a superclass like Integer or Numeric? > > Jeremy > --0015175df1620fc6c904b1b4bbea Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Jeremy,

I really think that

=A0 num= ber.positive?

is more readable than

=
=A0 number > 0

I think that using th= e positive? method condition is much more clear. On the other hand I think = that is not necessary to add nonpositive? and nonnegative? you could use

=A0 not number.positive?

or

=A0 not number.negative?

Ab= out to add this method to Fixnum, Integer or Numeric you must excuse me bec= ause I'm starting to understand the Ruby Core. I though that Fixnum is = the base of Integer number and adding a C function to it will solve the pro= blem and make the condition faster. About the zero condition, I have my dou= bts but maybe a solution would be return nil.

Regards.
=A0=A0

2011/11/14 Jeremy Evan= s <code@jeremyevans.net><= br>>
> On 11/15 12:58, Jos? Francisco Calvo Moreno wrote:
> = > Hi all!
> >
> > In order to increase Ruby code readability I have me= t many times with
> > the need to add the following methods to Fix= num:
> >
> > =A0 #positive? =A0(return true if number >= ; 0, return false if number < 0)
> > =A0 #negative? (return true if number < 0, return false if num= ber > 0)
>
> Is
>
> =A0number.positive?
><= br>> really more readable than
>
> =A0number > 0
><= br> > I personally think the > operator is more readable, so I would be> against including this in core. =A0Plus, your description of the met= hods
> does not describe the behavior of the case where number =3D=3D= 0 (though I
> can guess the desired behavior). =A0By your reasoning, we would also h= ave
> to add nonpositive? and nonnegative? for <=3D 0 and >=3D = 0.
>
> If you were going to add it, why would you want to add t= his just to
> Fixnum instead of a superclass like Integer or Numeric?
>
>= ; Jeremy
>

--0015175df1620fc6c904b1b4bbea--