You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Mathias Fonseca (JIRA)" <ji...@apache.org> on 2015/06/02 23:02:49 UTC

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

Mathias Fonseca created GROOVY-7450:
---------------------------------------

             Summary: 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)