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 CDE7B200D6B for ; Sun, 31 Dec 2017 17:29:30 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CC3BF160C24; Sun, 31 Dec 2017 16:29:30 +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 1AE0B160C09 for ; Sun, 31 Dec 2017 17:29:29 +0100 (CET) Received: (qmail 82959 invoked by uid 500); 31 Dec 2017 16:29:29 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 82949 invoked by uid 99); 31 Dec 2017 16:29:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 Dec 2017 16:29:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 8A3CB1806B7 for ; Sun, 31 Dec 2017 16:29:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.701 X-Spam-Level: X-Spam-Status: No, score=-0.701 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ifDR0j2oBH8G for ; Sun, 31 Dec 2017 16:29:27 +0000 (UTC) Received: from mx27lb.world4you.com (mx27lb.world4you.com [81.19.149.137]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 0FA475F254 for ; Sun, 31 Dec 2017 16:29:27 +0000 (UTC) Received: from [84.112.214.51] (helo=[192.168.0.24]) by mx27lb.world4you.com with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.84_2) (envelope-from ) id 1eVgUC-0004Lj-Lg; Sun, 31 Dec 2017 17:29:20 +0100 Subject: Re: About adding DGM startsWith(String...) and endsWith(String...) To: dev@groovy.apache.org, Jochen Theodorou References: <1514723084287-0.post@n5.nabble.com> From: MG Message-ID: Date: Sun, 31 Dec 2017 17:29:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-SA-Do-Not-Run: Yes X-AV-Do-Run: Yes X-SA-Exim-Connect-IP: 84.112.214.51 X-SA-Exim-Mail-From: mgbiz@arscreat.com X-SA-Exim-Scanned: No (on mx27lb.world4you.com); SAEximRunCond expanded to false archived-at: Sun, 31 Dec 2017 16:29:31 -0000 +1 on startsWithAny or startsWithAnyOf (was thinking along the same line after my reply). Better expresses the use and keeps startsWith free to be extended with other arguments in the future. @Offset parameter: I tend to be for offering more functionality - though I must admit I do not see the applications here, and "startsWith with an offset" (even if Java already uses it) is a bit weird, since it is more of a "containsAt". Detail question: Would the offset parameter be the first (imho better to read) or the last (as in Java) parameter ? On 31.12.2017 16:16, Jochen Theodorou wrote: > On 31.12.2017 13:24, Daniel.Sun wrote: >> Hi all, >> >>        I am going to add startsWith(String...) and >> endsWith(String...) for >> java.lang.String(i.e. if and only if the string starts with/ends with >> any >> specified strings, return true), because many senarios require them. For >> example: >> >> The following code >> https://github.com/apache/groovy/blob/master/gradle/assemble.gradle#L352-L355 >> can be simplified as >>      it.file.name.startsWith('asm-', 'antlr-', 'antlr4-') >> >>      The similar senario appears at: >> https://github.com/apache/groovy/blob/master/gradle/assemble.gradle#L366-L369 >> >> >>      Any thoughts? > > I think the name should express the iterative aspect something like > startsWithAny of findStartsWith. And then there is also the variant > with an offset in java-lang.String. Would we have that as well? > > But frankly my feeling is that it would be better to find a generic > solution for this kind of construct, instead of having more methods in > DGM. But that not stop us in the past either and I do not have an idea > to present here as well. > > bye Jochen >