You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Will Erickson (JIRA)" <ji...@apache.org> on 2016/10/21 21:09:58 UTC

[jira] [Commented] (GROOVY-7450) List contains String and GString

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

Will Erickson commented on GROOVY-7450:
---------------------------------------

I just ran into this today.

Is there something wrong with [~mathifonseca]'s suggested fix for this?

> List contains String and GString
> --------------------------------
>
>                 Key: GROOVY-7450
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7450
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Mathias Fonseca
>
> I have a List of Strings (Java Strings, not GStrings). On the other hand, I have two String variables. I concat those variables in a new one and get a GString instance.
> The problem is that if I then try to find an element in the list by using contains and passing the GString variable to find, it returns false.
> My workaround for now is to use find instead of contains, but shouldn't it be corrected?
> {code:java}
> ​def list = ['word1 word2','word3 word4']
> def w1 = 'word1'
> def w2 = 'word2'
> def word = "$w1 $w2"
> assert list.contains(word) //should return true
> assert list.find { it == word }​ //returns true
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)