Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make any2array return empty array on empty string #930

Merged
merged 1 commit into from
Jun 27, 2018

Conversation

jbro
Copy link
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