Feature #3871
Allow for searching in Arrays
| Status: | Closed | Start date: | 05/25/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | parser | |||
| Target version: | 2.6.0 | |||
| Affected Puppet version: | 0.25.5 | Branch: | http://github.com/masterzen/puppet/tree/tickets/master/3871 | |
| Keywords: | ||||
| Votes: | 0 |
Description
Hey,
It would be awesome if we could do something like:
if "bla" in $array {
# do something...
}
It would allow for conditions in defined types for instance.
Associated revisions
Fix #3871 – Add the ‘in’ operator
This operator allows to find if the left operand is in the right one. The left operand must be resort to a string, but the right operand can be: * a string * an array * a hash (the search is done on the keys)
This syntax can be used in any place where an expression is supported.
Syntax: $eatme = ‘eat’ if $eatme in [‘ate’, ‘eat’] { … }
$value = ‘beat generation’ if ‘eat’ in $value { notice(“on the road”) }
Signed-off-by: Brice Figureau brice-puppet@daysofwonder.com
History
Updated by James Turnbull over 1 year ago
- Category set to RAL
- Status changed from Unreviewed to Needs Decision
- Assignee set to Luke Kanies
Updated by Tim Stoop over 1 year ago
Brice was already planning on doing this, I believe. That’s what he told me just before puppetcamp, anyway.
Updated by Luke Kanies over 1 year ago
- Category changed from RAL to parser
- Status changed from Needs Decision to Accepted
- Assignee deleted (
Luke Kanies)
I’m comfortable with this, or some form of it.
Updated by Nigel Kersten over 1 year ago
hell yes please!
Updated by Nigel Kersten over 1 year ago
would it be insane to make the “in” operator work on strings and arrays?
if "ate" in "grateful" {
}
if "ate" in ["ate", "eat"] {
}
Updated by James Turnbull over 1 year ago
- Status changed from Accepted to Ready For Checkin
- Target version set to 2.6.0
- Branch set to http://github.com/masterzen/puppet/tree/tickets/master/3871
Updated by Nick Lewis over 1 year ago
- Status changed from Ready For Checkin to Closed
Pushed in 9592dd896c6aab9a3e9b0181c943e7c9ba3d2d6d in master