Hi Matt, Is your aim to avoid the duplication? If so, perhaps you could just use simple composition, eg:
$defaults = { 'foo1' => 'bar', #[...] 'foo99' => 'baz', } $h = $defaults + { 'foo100' => 'h', } $g = $defaults + { 'foo100' => 'g', } If you need more flexibility though, hiera might be the nicer way to achieve it. Cheers Jesse On Tuesday, 24 October 2023 at 2:18:26 am UTC+11 Puppet Users wrote: > Hello, > > I have a variety of hashes that have similar content: > > $h = { > 'foo1' => 'bar', > [...] > 'foo99' => 'baz', > 'foo100' => 'h', > } > > $g = { > 'foo1' => 'bar', > [...] > 'foo99' => 'baz', > 'foo100' => 'g', > } > > I'd like to have a function or similar mechanism: > > $h = helper_module::get_hash_defaults() > > but be able to override various keys/parameters in the get_hash_defaults > function: > > $h = helper_module::get_hash_defaults( > 'foo100' => 'h', > ) > > $h = helper_module::get_hash_defaults( > 'foo100' => 'g', > ) > > but functions only take parameters by position. > > Does anyone have any clever hacks I could try to mimic passing arguments > by name? > > Thanks for any help! > > -m > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ccb3fec7-9d50-4f9a-8c6e-13c656fdfb1fn%40googlegroups.com.