this is necessary because we can't use .dup on nil . 
as a side effect we only attribute result value if args[0] is not nil. 

If the function receives a empty or nil argument, 
we won't have the result value attributed, but args[0] will always exists, so 
it would be better to check the type of arg[0] instead of result. 

when i implemented this i had thought about other ways of making this change: 

basically we could: 
1.  do .dup on the result when its value is attributed (method i used) 
or 
2. before running the delete or delete_if commands (in this case we would need to have
.dup in two different places. ) 
 
as see by the following example : 
result = args[0]
if result.is_a?(hash)
  **result = result.dup**.delete_if {|key, val| val.equal? :undef} 
elsif result.is_a?(Array)
  **result = result.dup**.delete :undef 
else
       raise(Puppet::ParseError,  .....REDACTED....

if you prefer method 2, or have other suggestion, I could change that.