Jakarta Commons Developers List
> Subject: Re: [lang] ArrayUtils.lastIndex
>
> My argument is that -1 is *such* a well-known value for not found that
> doesn't need to be defined as a constant. Sun doesn't define it as a
> constant in String or List for example. Nor d
My argument is that -1 is *such* a well-known value for not found that
doesn't need to be defined as a constant. Sun doesn't define it as a
constant in String or List for example. Nor does it define the empty string.
It depends on whether you in your calling code want to write:
if (ArrayUtils.in
ns still
an integer, but this time representing a completely different idea:
there is no index.
Isn't this a perfect example of a "magic number"?
Gary
> -Original Message-
> From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
> Sent: Sunday, October 10, 2004 11:25
>
seing "-1" and wondering, why not -2 or -3.
Gary
-Original Message-
From: Michael McGrady [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 09, 2004 14:53
To: Jakarta Commons Developers List
Subject: Re: [lang] ArrayUtils.lastIndex
I don't have a vote, but, if I did
---
> From: Michael McGrady [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 09, 2004 14:53
> To: Jakarta Commons Developers List
> Subject: Re: [lang] ArrayUtils.lastIndex
>
> I don't have a vote, but, if I did, I would vote very high in favor of
> all such decisions
I don't have a vote, but, if I did, I would vote very high in favor of
all such decisions. Hard coding is not good for lots of reasons, in my
opinion. If the -1s mean the same thing "all over the place", then they
should be identified as to what they mean in all places with the value
put in o
My opinion is that assigning constants for these kinds of things bloats the
source and byte code to no gain. But we already seem to have gone down this
route in other classes, so consider it a -0.
Stephen
- Original Message -
From: "Gary Gregory" <[EMAIL PROTECTED]>
Speaking of "-1"s. I w
Speaking of "-1"s. I wonder if we should create a constant for the "-1
means NOT_FOUND" concept. This value is hard coded all over the place in
ArrayUtils. It seems to me like it would make the code more readable.
Gary
> -Original Message-
> From: Stephen Colebourne [mailto:[EMAIL PROTECT