Groovy
  1. Groovy
  2. GROOVY-3789

switch should be expression like if

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.5, 1.7-beta-2
    • Fix Version/s: 1.6.5, 1.7-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      The code

      #! /usr/bin/env groovy
      
      def ifClosure = { ->
        if ( 0 ) { 10 }
        else { 20 }
      }
      
      def switchClosure = { ->
        switch ( 0 ) {
        case 0 : 10 ; break
        default : 20 ; break
        }
      }
      
      println ifClosure ( )
      println switchClosure ( )
      

      produces the output:

      20
      null

      which seems inconsistent.

        Activity

        Russel Winder created issue -
        Russel Winder made changes -
        Field Original Value New Value
        Affects Version/s 1.7-beta-2 [ 15540 ]
        Affects Version/s 1.6.5 [ 15539 ]
        Roshan Dawrani made changes -
        Assignee Roshan Dawrani [ roshandawrani ]
        Roshan Dawrani made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.7-beta-2 [ 15540 ]
        Fix Version/s 1.6.5 [ 15539 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12732760 ] Default workflow, editable Closed status [ 12744564 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12970486 ] Default workflow, editable Closed status [ 12978260 ]

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Russel Winder
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development