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

It would be Groovy if postfix conditionals were available like in Perl

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.0-beta-1
    • 4.x
    • syntax
    • None
    • any

    Description

      I would be nice if Groovy supported Perl's postfix conditionals.
      This is something I really miss from Perl.
      In Perl you can supply a boolean condition to the loop control next, last or redo statements.
      In Groovy it would be cool if we could do the same with continue or break.
      small example

      while (some condition) {
           if (condition) continue
           if (another_condition) break
      }
      

      example using postfix loop control

      while (some condition) {
           continue if condition
           break if another_condition
      }
      

      or

      LABEL:
      while (some condition) {
           continue LABEL if condition
           break LABEL if another_condition
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            ericksn ericksn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: