groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8741) Single character GString and '==' with Character or Number
Date Sat, 18 Aug 2018 05:51:00 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16584651#comment-16584651
] 

ASF GitHub Bot commented on GROOVY-8741:
----------------------------------------

Github user danielsun1106 commented on the pull request:

    https://github.com/apache/groovy/commit/35a3df1436b76f315a925f7d30479c8d092805c0#commitcomment-30151884
  
    GROOVY-8741: Make single character GString behave like similar String in '==' #782


> Single character GString and '==' with Character or Number
> ----------------------------------------------------------
>
>                 Key: GROOVY-8741
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8741
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Mikko Värri
>            Priority: Major
>
> Similar things have been touched before, like GROOVY-2340. But I didn't see exactly this.
I'm not sure if single character GStrings are even a thing. Sorry if they aren't.
> But I found the following a bit inconsistent:
> {code:java}
> final String S = 'A'
> final Character C = 'A'
> final GString G = "$S"
> final Number N = 65
> assert C == S && S == G // 1a
> assert C      ==      G // 1b
> assert S == C && G == S // 2a
> //assert      G == C      // 2b, fails, inconsistent with 2a and 1b
> assert N == S && S == G // 3a
> //assert N      ==      G // 3b, fails, inconsistent with 3a
> assert S == N && G == S // 4a
> //assert      G == N      // 4b, fails, inconsistent with 4a
> {code}
> So, a single character GString equals a character, but only if it is on RHS. It doesn't
equal a number, ever. I wonder if it should behave like String here.
> If there's interest in "fixing" this, I've got a patch that allows all those asserts
pass and doesn't seem to fail any of the existing test cases.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message