groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anand (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7908) groovy default list.find == item is giving false even if the item is present
Date Tue, 16 Aug 2016 10:32:20 GMT

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

Anand commented on GROOVY-7908:
-------------------------------

i was in a state of mind that doing list.find() == item would give me true even  if the item
is present at any position. Is my understanding correct ? if NO then my Bad this is not a
bug. But if yes then in the line  names << searchItem in the code i have added
the searchItem to the list but still names.find() == searchItem is giving me false.

It cannot be searchItem if it is no in the list, still it returns something... so what is
it?

names.find() is returning the first item  in the list.


> groovy default list.find == item  is giving false even if the item is present
> -----------------------------------------------------------------------------
>
>                 Key: GROOVY-7908
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7908
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.4.7
>         Environment: Ubuntu 16.04
>            Reporter: Anand
>            Priority: Minor
>
> For the following script,
> {code} def names = []
> names << "Anand"
> names << "Aditya"
> names << "Abhi"
> def searchItem = "bug"
> if (names.find() == searchItem)
>     println "item found "
> else
>     println "Item not found "
> println "adding the Item"
> names << searchItem
> println "Item added"
> println "values: $names"
> println "trying again"
> if (names.find() == searchItem)
>     println "Item found "
> else
>     println "Item still not found "  {code}
> In list there first the search item is not present and it has yielded false but then
i added the item and still find method is giving false. The opposite case work well i.e if
initially item is there it gives true and then if i remove it then it gives false.
> Is it how it is designed to work or is this a bug.



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

Mime
View raw message