groovy
  1. groovy
  2. GROOVY-3789

switch should be expression like if

    Details

    • Type: Bug Bug
    • Status: Closed 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
    • Number of attachments :
      0

      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

        Hide
        Roshan Dawrani added a comment -

        Fixed

        Show
        Roshan Dawrani added a comment - Fixed

          People

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

            Dates

            • Created:
              Updated:
              Resolved: