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

Also remove values that are nil #707

Closed
wants to merge 1 commit into from
Closed

Also remove values that are nil #707

wants to merge 1 commit into from

Conversation

mattkenn4545
Copy link

No description provided.

@wilson208
Copy link
Contributor

@mattkenn4545 I am thinking that this change may be slightly misleading, nil != Undef and the naming of this function is delete_undef_values . Perhaps this should be broken out to its own function delete_nil_values or perhaps add an additional parameter delete_nil_values or similar to delete_undef_values which defaults to false to ensure we do not modify current behaviour.

@mattkenn4545
Copy link
Author

However there is no nil value in the DSL.

@hlindberg
Copy link
Contributor

This is the same as filtering for match on Undef in puppet.

function without_undef(Collection $val) { filter |$k, $v| { $v !~ Undef and $k !~ Undef}) }

The matching with Undef will handle both Ruby nil and Ruby :undef. It checks if key is of Undef type as well as the value. It works for both arrays and hashes (i.e. a Collection)

I think this function is better implemented as a puppet language function as it removes the concern of having to deal with the Ruby symbol :undef.

@eputnam eputnam closed this Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants