Feature #8708
Add method to detect existance of hash keys
| Status: | Closed | Start date: | 07/29/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | function | |||
| Target version: | stdlib 1.0.0 | |||
| Keywords: | discovered_task, stdlib | Branch: | ||
| Votes: | 1 |
Description
It is currently difficult to determine if a hash contains a certain key.
Until #8705 is resolved, we need a method that can take a hash and determine if it has a certain key.
I propose that we introduce the method has_key
if has_key({}, 'key') {
# should never get here
}
History
Updated by Dan Bode 10 months ago
- Status changed from Unreviewed to Merged - Pending Release
commit b1beaec2da36aa2312f959b1521137f5df96608f Author: Dan BodeDate: Fri Jul 29 15:10:13 2011 -0700 (#8708) Add has_key function It is difficult to use existance of keys in a hash as a boolean condition in Puppet (see #8705) This function provides a working solution until the underlying issue in Puppet can be resolved. Reviewed-by: Jeff McCune
Updated by Jeff McCune 10 months ago
- Category set to stdlib
- Status changed from Merged - Pending Release to Closed
- Assignee set to Jeff McCune
Updated by Krzysztof Wilczynski 7 months ago
Jeff McCune wrote:
Released¶
Released with 2.0.0 just now.
I have similar version:
Plus “has_value” as well:
I will work on adding it to the standard library.
KW
Updated by Jeff McCune about 1 month ago
- Project changed from Puppet Labs Modules to Standard Library
- Category deleted (
stdlib)
Updated by Jeff McCune about 1 month ago
- Category set to function
- Target version set to stdlib 1.0.0