Paul King | 24 Jun 15:17

[groovy-dev] proposed minor breaking change: isCase for Gstring


At the moment if we run this script:

def one = 'one'
def two = 'two'

switch('onetwo') {
  case 'onetwo': println true
  default: println false
}

switch("$one$two") {
  case 'onetwo': println true
  default: println false
}

switch('onetwo') {
  case "$one$two": println true
  default: println false
}

switch("one${two}") {
  case "${one}two": println true
  default: println false
}

it prints:

true
true
(Continue reading)

Paul King | 24 Jun 15:26

Re: [groovy-dev] proposed minor breaking change: isCase for Gstring


I should point out that the need for this one line change would
go away if we ever got to the point where equality of Strings
and GStrings was catered for in the natural way (an issue exists
for this already). But given that issue is hard, this change
would solve one of the downsides of the current situation in
the meantime and would do no harm if we ever changed that down
the track.

Paul.

Paul King wrote:
> 
> At the moment if we run this script:
> 
> def one = 'one'
> def two = 'two'
> 
> switch('onetwo') {
>  case 'onetwo': println true
>  default: println false
> }
> 
> switch("$one$two") {
>  case 'onetwo': println true
>  default: println false
> }
> 
> switch('onetwo') {
>  case "$one$two": println true
(Continue reading)

Guillaume Laforge | 24 Jun 15:57

Re: [groovy-dev] proposed minor breaking change: isCase for Gstring

Some good reasons were raised by Jochen on this GString/String
equality as far as I recall, so I'm not sure allowing complete
equality between both type would be the way to go -- but I'll have to
re-read the comments on that issue to be sure.
I think in the case you present, it's probably the best thing to do to
give isCase() on GStrings.

On Tue, Jun 24, 2008 at 3:26 PM, Paul King <paulk@...> wrote:
>
> I should point out that the need for this one line change would
> go away if we ever got to the point where equality of Strings
> and GStrings was catered for in the natural way (an issue exists
> for this already). But given that issue is hard, this change
> would solve one of the downsides of the current situation in
> the meantime and would do no harm if we ever changed that down
> the track.
>
> Paul.
>
> Paul King wrote:
>>
>> At the moment if we run this script:
>>
>> def one = 'one'
>> def two = 'two'
>>
>> switch('onetwo') {
>>  case 'onetwo': println true
>>  default: println false
>> }
(Continue reading)

Paul King | 25 Jun 05:10

Re: [groovy-dev] proposed minor breaking change: isCase for Gstring

Guillaume Laforge wrote:
> Some good reasons were raised by Jochen on this GString/String
> equality as far as I recall, so I'm not sure allowing complete
> equality between both type would be the way to go -- but I'll have to
> re-read the comments on that issue to be sure.
> I think in the case you present, it's probably the best thing to do to
> give isCase() on GStrings.

Yes, I am not sure we will ever find a way to have both strict
and friendly equals wrapped into one concept. I suspect we actually
need to have two concepts. Anyway, I am not trying to solve that
one at this point. I'll create a Jira for the isCase() enhancement.

Paul.

> On Tue, Jun 24, 2008 at 3:26 PM, Paul King <paulk@...> wrote:
>> I should point out that the need for this one line change would
>> go away if we ever got to the point where equality of Strings
>> and GStrings was catered for in the natural way (an issue exists
>> for this already). But given that issue is hard, this change
>> would solve one of the downsides of the current situation in
>> the meantime and would do no harm if we ever changed that down
>> the track.
>>
>> Paul.
>>
>> Paul King wrote:
>>> At the moment if we run this script:
>>>
>>> def one = 'one'
(Continue reading)


Gmane