1 # Returns the type when passed a value.
3 # @example how to compare values' types
4 # # compare the types of two values
5 # if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") }
6 # @example how to compare against an abstract type
7 # unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") }
8 # unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") }
10 # See the documentation for "The Puppet Type System" for more information about types.
11 # See the `assert_type()` function for flexible ways to assert the type of a value.
13 Puppet::Functions.create_function(:type_of) do
15 Puppet::Pops::Types::TypeCalculator.infer_set(value)