4 module Puppet::Parser::Functions
5 newfunction(:reject, :type => :rvalue, :doc => <<-DOC) do |args|
6 This function searches through an array and rejects all elements that match
7 the provided regular expression.
11 reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
17 Note that since Puppet 4.0.0 the same is in general done with the filter function. Here is the
18 equivalence of the reject() function:
20 ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ }
24 raise Puppet::ParseError,
25 "reject(): Wrong number of arguments given #{args.size} for 2"
29 pattern = Regexp.new(args[1])
31 ary.reject { |e| e =~ pattern }
35 # vim: set ts=2 sw=2 et :