Skip to content

(#19272) Add has_element() function#130

Merged
jeffmccune merged 1 commit intopuppetlabs:masterfrom
jhoblitt:has_element
Feb 15, 2013
Merged

(#19272) Add has_element() function#130
jeffmccune merged 1 commit intopuppetlabs:masterfrom
jhoblitt:has_element

Conversation

@jhoblitt
Copy link
Copy Markdown

It is exceptionally difficult to determine if an array contains an element matching a specific value without an iteration or loop construct.

This function is the Puppet equivalent of Array.includes?(foo) in Ruby. The implementation is a verbatim copy of has_key() with the minor modifications needed to support arrays instead of hashes.

It is exceptionally difficult to determine if an array contains an element matching a specific value without an iteration or loop construct.

This function is the Puppet equivalent of Array.includes?(foo) in Ruby.  The implementation is a verbatim copy of has_key() with the minor modifications needed to support arrays instead of hashes.
@jeffmccune
Copy link
Copy Markdown
Contributor

This looks great. Thanks for the contribution and example specs.

jeffmccune pushed a commit that referenced this pull request Feb 15, 2013
(#19272) Add has_element() function
@jeffmccune jeffmccune merged commit f7a1818 into puppetlabs:master Feb 15, 2013
@duritong
Copy link
Copy Markdown
Contributor

As I commented in http://projects.puppetlabs.com/issues/19272 why is the in-expression not sufficient?

I think we should really not duplicate behavior in the stdlib that the language already provides. So if there is no extra benefit to the in-expression, I would propose to revert this merge.

jeffmccune pushed a commit that referenced this pull request Feb 15, 2013
This reverts commit f7a1818, reversing
changes made to 36a7b29.

I'm reverting this change because of concerns raised by Peter Meier that
it duplicates the "in" operator in the DSL.  The "in" operator is new
information that I did not posses when I made the decision to merge.
Because of this new information I'm un-merging and continuing the
discussion in the comments of
https://projects.puppetlabs.com/issues/19272

Reference: GH-130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants