On 08/14/2014 02:00 PM, Alan Bateman wrote:
On 14/08/2014 12:42, Claes Redestad wrote:

Noone brought it up, as far as I can recall. Since parseInt(String, int radix) already existed, I figured adding the range parameters to the end would be overall less awkward than to push the radix parameter right in the new methods. The chosen implementation maintains that the second parameter is always radix, which I think helps maintain consistency.
I think consistency could be argued both ways as the radix is also the last parameter in the existing methods. When I look at this method:

public static int parseInt(CharSequence s, int radix, int beginIndex, int endIndex)

and then feels more error prone than if the beginIndex/endIndex were immediately after the CharSequence.

I'm interested in other opinions on this.

-Alan.

'radix' parameter could be typed as short. It typically is called with a constant literal and beginIndex/endIndex are usually int expressions. This would catch majority of mistakes where the caller mixes the order. But would not be consistent with public methods though...


Peter

Reply via email to