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

Add a `convert_to` function that works like `new` but with type arg as second arg

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 5.4.0
    • Component/s: Functions, Language
    • Labels:
      None
    • Template:
    • Epic Link:
    • Sub-team:
    • Team:
      Platform Core
    • Story Points:
      1
    • Release Notes:
      New Feature
    • Release Notes Summary:
      A function named {{convert_to}} has been added that makes it possible to write code that is easier to read when transforming one data type to another when transformations occur in a sequence. Example {{"abc".convert_to(Array)}}.
    • QA Risk Assessment:
      Needs Assessment

      Description

      By adding a function `convert_to` that takes a value and a type in the reverse order from the `new` function sequences of transformations becomes easier to read.

      Instead of:

      Hash(Array("abc").map |$i,$v| { [$i, $v]})
      

      It is possible to write:

      "abc".convert_to(Array).map |$i,$v| { [$i, $v]}.convert_to(Hash)
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support