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

Empty primitive arrays evaluate to true

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.7.3
    • 1.7.4, 1.8-beta-1
    • Compiler
    • None

    Description

      In contrast to other empty collections, empty primitive arrays evaluate to true:

      def x = [] as int[]
      assert !x // fails!
      

      Empty non-primitive arrays behave as expected:

      def x = [] as String[]
      assert !x // passes
      

      Attachments

        1. GROOVY-4312.patch
          4 kB
          Peter Niederwieser

        Activity

          People

            guillaume Guillaume Sauthier
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: