Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-4643

Add return/next/break for iteration control

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.8.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide

      That:

      • break() breaks the innermost iteration
      • next(v) or next() returns v or undef respectively from a lambda, or function
      • return(v) or return() returns v or undef respectively from a function
      • that next and return have the same behavior in a function body
      • that a return from a lambda makes the function it is used in return
      • that errors are raised if the next/return/break "signal" reaches a scope where it is not allowed
      Show
      That: break() breaks the innermost iteration next(v) or next() returns v or undef respectively from a lambda, or function return(v) or return() returns v or undef respectively from a function that next and return have the same behavior in a function body that a return from a lambda makes the function it is used in return that errors are raised if the next/return/break "signal" reaches a scope where it is not allowed
    • Epic Link:
    • Story Points:
      3
    • Sprint:
      Language 2016-09-07
    • Release Notes:
      New Feature
    • Release Notes Summary:
      Hide
      The functions {{break()}}, {{next()}} and {{return()}} have been added to make it possible to do an "early exit" from a block of code. In summary {{break()}} will break the innermost iteration, {{next()}} will return from a lambda/block/class or resource body and {{return()}} will return from a function or class or resource body. See the respective function for more details.
      Show
      The functions {{break()}}, {{next()}} and {{return()}} have been added to make it possible to do an "early exit" from a block of code. In summary {{break()}} will break the innermost iteration, {{next()}} will return from a lambda/block/class or resource body and {{return()}} will return from a function or class or resource body. See the respective function for more details.

      Description

      It would be very convenient if we had the standard continue/next/break functions to control iterative functions like each. I imagine this has been discussed but wanted to put in my vote to add this feature.

      Eric Zounes I believe you were interested in this as well.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                john.duarte John Duarte
                Reporter:
                daniel.dreier Daniel Dreier
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: