Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3070E200BE1 for ; Mon, 19 Dec 2016 17:53:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 2F319160B21; Mon, 19 Dec 2016 16:53:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 788E9160B14 for ; Mon, 19 Dec 2016 17:52:59 +0100 (CET) Received: (qmail 93426 invoked by uid 500); 19 Dec 2016 16:52:58 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 93405 invoked by uid 99); 19 Dec 2016 16:52:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Dec 2016 16:52:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 5B94A2C03DE for ; Mon, 19 Dec 2016 16:52:58 +0000 (UTC) Date: Mon, 19 Dec 2016 16:52:58 +0000 (UTC) From: "Duncan Jones (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (LANG-1078) -1, 0 or error for String/Array operations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 19 Dec 2016 16:53:00 -0000 [ https://issues.apache.org/jira/browse/LANG-1078?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Duncan Jones closed LANG-1078. ------------------------------ Resolution: Not A Bug Assignee: Duncan Jones Fix Version/s: (was: Discussion) I would suggest any further discussion is continued on the developer mailing list. > -1, 0 or error for String/Array operations > ------------------------------------------ > > Key: LANG-1078 > URL: https://issues.apache.org/jira/browse/LANG-1078 > Project: Commons Lang > Issue Type: Wish > Components: lang.* > Reporter: haiyang li > Assignee: Duncan Jones > > what're design insights for below implementation: > #1: SHOULD throw exception for negative index? > {code:title= org.apache.commons.lang3.ArrayUtils.java|borderStyle=solid} > public static int indexOf(final boolean[] array, final boolean valueToFind, int startIndex) { > if (ArrayUtils.isEmpty(array)) { > return INDEX_NOT_FOUND; > } > if (startIndex < 0) { > startIndex = 0; > } > for (int i = startIndex; i < array.length; i++) { > if (valueToFind == array[i]) { > return i; > } > } > return INDEX_NOT_FOUND; > } > {code} > #2, Why does StringUtils.indexOf("", "") return 0, not -1? > first of all, "" is an empty String. '0' index doesn't exist in "". secondly, both null and "" strings are considered as none. I think it's inappropriate to say we found a none thing in position 0. so I suggest to return -1(not exists) to the index of any string in a null or "" string or null or "" empty string in any thing. > (i read the java doc and a few jira tickets. but didn't find the discussion related to this kind of issue. so i created a new ticket). -- This message was sent by Atlassian JIRA (v6.3.4#6332)