Skip to content

Make any2array return empty array on empty string#930

Merged
david22swan merged 1 commit intopuppetlabs:masterfrom
jbro:any2array
Jun 27, 2018
Merged

Make any2array return empty array on empty string#930
david22swan merged 1 commit intopuppetlabs:masterfrom
jbro:any2array

Conversation

@jbro
Copy link
Copy Markdown
Contributor

@jbro jbro commented Jun 26, 2018

any2array currently returns an array containing the empty string, when
given the empty string.

Example:

any2array('').each |$e| {
  notice('I\'m not empty!')
}

This is counter intuitive, as Puppet considers the empty string as
Strings nil value, for which the equivalent Array is the empty array.

This especially apparent when doing a lookup in a map with a non
existing key.

Example:

$config = {}
any2array($config['test']).each |$e| {
  notice('I\'m not empty!')
}

Both these cases print the string I'm not empty, this PR fixes that.

any2array currently returns an array containing the empty string, when
given the empty string.

Example:
```
any2array('').each |$e| {
  notice('I\'m not empty!')
}
```

This is counter intuitive, as Puppet considers the empty string as
Strings nil value, for which the equivalent Array is the empty array.

This especially apparent when doing a lookup in a map with a non
existing key.

Example:
```
$config = {}
any2array($config['test']).each |$e| {
  notice('I\'m not empty!')
}
```

Both these cases print the string "I'm not empty", this PR fixes that.
@david22swan david22swan merged commit 164e55a into puppetlabs:master Jun 27, 2018
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.

2 participants