Just FYI, there is some discussion of a partially-overlapping concern going on in this ticket:
http://projects.puppetlabs.com/issues/13210 On Wed, May 2, 2012 at 12:04 PM, Dan Bode <d...@puppetlabs.com> wrote: > > > On Wed, May 2, 2012 at 9:11 AM, Andrew Parker <a...@puppetlabs.com> wrote: > >> It can also be asked as "is passing nil or undefined as the value of a >> class parameter the same as not specifying that class parameter at the >> point of use at all?" >> > > I am pretty sure that this behavior as it relates to undef is already > specified behavior in Puppet. > > >> This way of phrasing it makes me think twice about this behavior, because >> it now means that you can't look just at the point of use to determine if >> you are going to be using the default value or not, now you need to take >> into account the data that is going to be present at compile time. >> >> On May 1, 2012, at 9:16 PM, Dan Bode wrote: >> >> So, I dopped into the debugger with: >> >> $x = inline_template("<%= require 'ruby-debug';debugger;puts 'foo' %>" >> >> and realized that the value returned from the statement: >> >> $var1_override = $override_hash['var1'] >> >> is actually nil. >> >> So an easier version of my question is rather or not nil can be treated >> the same as undefined in Puppet. >> >> On Tue, May 1, 2012 at 9:06 PM, Dan Bode <d...@puppetlabs.com> wrote: >> >>> Hi all, >>> >>> I have run into an example where Puppet behaves exactly like I hoped it >>> would. I am a little concerned that it may just be a coincidence that it >>> happens to work like this. My question is rather or not the following is >>> specified behavior that I can take advantage of (I may take advantage of it >>> anyways, the question is actually rather I should be concerned about it >>> working in the future :) ) >>> >>> My use case: >>> >>> Supposed I have a class that has parameters that have defaults specified: >>> >>> class one( >>> $var1 = 'default1', >>> $var2 = 'default2' >>> ) { >>> >>> notify { $var1: } >>> notify { $var2: } >>> } >>> >>> I want to call this class from another class, and that has a class >>> parameter that accepts a hash that is used to potentially override various >>> parameters from class 'one' >>> >>> class two( >>> $override_hash = {} >>> ) { >>> >>> $var1_override = $override_hash['var1'] >>> >>> class { 'one': >>> var1 => $var1_override >>> } >>> } >>> >>> class { 'two': } >>> >>> I was hoping that var1 from class one would not be overridden if the key >>> var1 did not exist in the hash (I was hoping that it would be equivalent to >>> passing undef) >>> >>> >>> And that is actually exactly how it worked. >>> >>> Is that on purpose? I did not find anything about this in the >>> documentation. >>> >>> regards, >>> >>> Dan >>> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Developers" group. >> To post to this group, send email to puppet-dev@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-dev+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-dev?hl=en. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Developers" group. >> To post to this group, send email to puppet-dev@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-dev+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-dev?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to puppet-dev@googlegroups.com. > To unsubscribe from this group, send email to > puppet-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.