groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathias Fonseca (JIRA)" <>
Subject [jira] [Created] (GROOVY-7450) List contains String and GString
Date Tue, 02 Jun 2015 21:02:49 GMT
Mathias Fonseca created GROOVY-7450:

             Summary: List contains String and GString
                 Key: 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?

​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

This message was sent by Atlassian JIRA

View raw message