4 module Puppet::Parser::Functions
5 newfunction(:dig, :type => :rvalue, :doc => <<-DOC
7 **DEPRECATED** Retrieves a value within multiple layers of hashes and arrays via an
8 array of keys containing a path.
11 The function goes through the structure by each path component and tries to return
12 the value at the end of the path.
14 In addition to the required path argument, the function accepts the default argument.
15 It is returned if the path is not correct, if no value was found, or if any other error
29 $value = dig($data, ['a', 'b', 2])
32 # with all possible options
33 $value = dig($data, ['a', 'b', 2], 'not_found')
36 # using the default value
37 $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
38 # $value = 'not_found'
41 1. `$data` The data structure we are working with.
42 2. `['a', 'b', 2]` The path array.
43 3. `not_found` The default value. It is returned if nothing is found.
46 **Deprecated** This function has been replaced with a built-in
47 [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of
48 Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version.
51 warning('dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.')
52 unless Puppet::Parser::Functions.autoloader.loaded?(:dig44)
53 Puppet::Parser::Functions.autoloader.load(:dig44)
55 function_dig44(arguments)