2 # Returns the type of the passed value.
4 # @example how to compare values' types
5 # # compare the types of two values
6 # if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") }
7 # @example how to compare against an abstract type
8 # unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") }
9 # unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") }
11 # See the documentation for "The Puppet Type System" for more information about types.
12 # See the `assert_type()` function for flexible ways to assert the type of a value.
14 # The built-in type() function in puppet is generally preferred over this function
15 # this function is provided for backwards compatibility.
16 Puppet::Functions.create_function(:type_of) do
18 # the type of the passed value
22 Puppet::Pops::Types::TypeCalculator.infer_set(value)