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

Support a single _ to mean ignored parameter

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Low
    • Resolution: Won't Fix
    • None
    • None
    • Language

    Description

      It is of value to be able to define that a parameter should be ignored. This helps in situations where a lambda needs to have several parameters, but only some of them are actually needed. The user must otherwise name the parameter. Code checking (that we do not have yet though) would then find a declared parameter that is unused.

      Using a _ instead of a parameter name also serves as a clear indication that it is ignored.

      There should be no problems introducing a single _ as a keyword as that is not a meaningful bare word,

      Here is an example:

      {a => 10, b => 20}.each |$key, _ | { notice $key }
      

      There are other uses cases for the single underscore, it does not always mean ignore, it can also be used as place to put a single injected values, and other use cases. The _ alone should be thought of as anonymous identifier or "Jane Doe".

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              henrik.lindberg Henrik Lindberg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support