Hello,
That form for Integer is not good as it is not consistent
with the form
for String. Test with n = {-10, 0, 10}. Good day.
Yemi Bedu
P&R Fasteners, Inc.
P&R Castings, LLC.
325 Pierce St
Somerset, NJ 08873
(T) 732-302-3600
(F) 732-302-3636
-----Original Message-----
From: Trans [mailto:transfire gmail.com]
Sent: Friday, March 14, 2008 12:26 PM
To: ruby-core ruby-lang.org
Subject: Re: next(n), succ(n) ?
On Mar 4, 8:47 am, Trans <transf... gmail.com> wrote:
> Can anyone see any reason against adding an optional
parameter to
> #succ/#next? Eg.
>
> def succ(n=1)
> s = self
> n.times { s = s.next }
> s
> end
>
> It might be useful in some cases as an optimization.
For instance in
> Integer:
>
> def succ(n=1)
> self + n
> end
>
> I ask not just a possible suggestion for Ruby itself,
but mainly b/c
> it's one of the few core overrides I provide in Facets,
and I want to
> make sure that there isn't some substantial issue with
the idea that
> should convince me to take it out.
No one has any thoughts on this whatsoever?
T.
|