[PUP-8693] Add a compare() function Created: 2018/05/03  Updated: 2018/09/19  Resolved: 2018/08/03

Status: Closed
Project: Puppet
Component/s: Docs
Affects Version/s: None
Fix Version/s: PUP 6.0.0

Type: New Feature Priority: Normal
Reporter: Henrik Lindberg Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Epic Link: stdlib to pup
Sub-team: Language
Team: Platform Core
Release Notes: New Feature
Release Notes Summary: 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.
QA Risk Assessment: 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.



 Comments   
Comment by Josh Cooper [ 2018/08/03 ]

Merged to puppet#master in https://github.com/puppetlabs/puppet/commit/274a1e0c35b40a1e3377db3cee0f4ccc78b55a17

Comment by Josh Cooper [ 2018/08/03 ]

Helen Campbell, Thomas Honey could you verify that stdlib contains the deprecation warnings Henrik Lindberg mentioned?

Comment by Josh Cooper [ 2018/08/03 ]

This passed CI awhile ago, resolving.

Generated at Mon Jan 27 10:11:02 PST 2020 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.