4 module Puppet::Parser::Functions
5 newfunction(:difference, :type => :rvalue, :doc => <<-DOC
6 This function returns the difference between two arrays.
7 The returned array is a copy of the original array, removing any items that
8 also appear in the second array.
12 difference(["a","b","c"],["b","c","d"])
16 Note: Since Puppet 4 the minus (-) operator in the Puppet language does the same thing:
18 ['a', 'b', 'c'] - ['b', 'c', 'd']
24 # Two arguments are required
25 raise(Puppet::ParseError, "difference(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2
30 unless first.is_a?(Array) && second.is_a?(Array)
31 raise(Puppet::ParseError, 'difference(): Requires 2 arrays')
34 result = first - second
40 # vim: set ts=2 sw=2 et :