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

Add a compare() function

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.0.0
    • Docs
    • None
    • New Feature
    • Hide
      A {{compare(a,b)}} function has been added that returns -1, 0, or 1 depending on if a is before b, same as b, or after b. The function works with the comparable types: String, Numeric, Semver, Timestamp, and Timespan. For String comparison it is possible to ignore or take case into account.
      Show
      A {{compare(a,b)}} function has been added that returns -1, 0, or 1 depending on if a is before b, same as b, or after b. The function works with the comparable types: String, Numeric, Semver, Timestamp, and Timespan. For String comparison it is possible to ignore or take case into account.
    • Needs Assessment

    Description

      In PUP-8603, the functions min and max are added. For backwards compatibility reasons they must continue to compare values with unwanted/strange automatic type conversion. In order to give users a sane alternative those functions will accept a lambda to enable taking over the responsibility to compare. To facilitate that, a compare(a,b) function should be added that returns -1, 0, 1 depending on the order of the values.

      In addition, when compare is given two strings, it should accept a third Boolean argument to control if string comparison ignores case (true - by default), or not.

      Attachments

        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