Issue #6621 has been updated by Stefan Schulte.

Puppet has undef as a special value. undef evaluates to false and it can be 
used to unset defaults. I did a short test
<pre>
define test($var = undef) {
  if $var {
    notice "$name is true"
  }
  else {
    notice "$name is false"
  }
}

test { "empty string"  : var => "" }
test { "unquoted nil"  : var => nil }
test { "quoted nil"    : var => "nil"}
test { "quoted undef"  : var => "undef" }
test { "unquoted undef": }
</pre>
empty string and unquoted undef evaluate to false. If "" has to be true in your 
use case, you can change `if $var` to `if $var != undef`
----------------------------------------
Feature #6621: Provide a nil type in the Puppet language
https://projects.puppetlabs.com/issues/6621

Author: Oliver Hookins
Status: Unreviewed
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 2.6.5
Keywords: 
Branch: 


Currently there is no way to semantically convey the concept of nil, as Ruby 
understands it.

nil currently evaluates to true and is internally converted to a string 'nil', 
and '' evaluates (somewhat confusingly) to false. However, the empty string is 
a permissible configuration value whereas nil inherently is not. Furthermore 
non-empty strings evaluate to true unlike the empty string.

My use case, to put it very simply, is to work around some limitations of 
communicating information between the external node classifier interface and 
Puppet itself, since once you pass a nil value through the interface to Puppet, 
nil loses its semantic value.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to