groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <mg...@arscreat.com>
Subject Re: About adding DGM startsWith(String...) and endsWith(String...)
Date Sun, 31 Dec 2017 16:29:19 GMT
+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
>


Mime
View raw message