Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7908

groovy default list.find == item is giving false even if the item is present

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Bug
    • 2.4.7
    • None
    • groovy-jdk
    • None
    • Ubuntu 16.04

    Description

      For the following script,

       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 "  

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            upadhyayap Anand
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: