From 27c3b644b00bb2eca0cb819c55d7d348a1caa01b Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Tue, 16 Aug 2011 15:57:47 -0700 Subject: Docs: Improve example in merge function This commit replaces the example in the merge function with a much clearer one. It also mentions that the rightmost value wins in the event of duplicated hash keys. --- lib/puppet/parser/functions/merge.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/puppet/parser/functions/merge.rb') diff --git a/lib/puppet/parser/functions/merge.rb b/lib/puppet/parser/functions/merge.rb index d2dc0f9..6ec085e 100644 --- a/lib/puppet/parser/functions/merge.rb +++ b/lib/puppet/parser/functions/merge.rb @@ -4,10 +4,13 @@ module Puppet::Parser::Functions For example: - $hash1 = {'one' => 1, 'two', => 2} - $hash1 = {'two' => 2, 'three', => 2} - $merged_hash = merge($hash1, $hash2) - # merged_hash = {'one' => 1, 'two' => 2, 'three' => 2} + $hash1 = {'one' => 1, 'two', => 2} + $hash2 = {'two' => 'dos', 'three', => 'tres'} + $merged_hash = merge($hash1, $hash2) + # The resulting hash is equivalent to: + # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} + + When there is a duplicate key, the key in the rightmost hash will "win." ENDHEREDOC -- cgit v1.2.3