From 678c5a2de41c8223f55c960b9eca51770c7551e2 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Wed, 30 Nov 2016 09:28:58 -0800 Subject: [PATCH 1/2] Indicate that the type function is preferred Prior to this commit, users coming to the type_of function would not realize that the type function in puppet does the same thing and is preferred over type_of. After this commit, we have a comment indicating the above. --- lib/puppet/functions/type_of.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puppet/functions/type_of.rb b/lib/puppet/functions/type_of.rb index 02cdd4db7..01f1f49ef 100644 --- a/lib/puppet/functions/type_of.rb +++ b/lib/puppet/functions/type_of.rb @@ -10,6 +10,8 @@ # See the documentation for "The Puppet Type System" for more information about types. # See the `assert_type()` function for flexible ways to assert the type of a value. # +# The built-in type() function in puppet is generally preferred over this function +# this function is provided for backwards compatibility. Puppet::Functions.create_function(:type_of) do def type_of(value) Puppet::Pops::Types::TypeCalculator.infer_set(value) From 21862b0558b8d33c142c144e3bc19a74b0d9d027 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Wed, 30 Nov 2016 09:48:32 -0800 Subject: [PATCH 2/2] Indicate type function is preferred The type function in Puppet is preferred over the type_of function here in stdlib. This commit adds this information to the README --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 3e937b12e..a6b7bda8b 100644 --- a/README.markdown +++ b/README.markdown @@ -1190,6 +1190,8 @@ Returns a string description of the type when passed a value. Type can be a stri #### `type_of` +This function is provided for backwards compatibility but is generally not preferred over the built-in [type() function](https://docs.puppet.com/puppet/latest/reference/function.html#type) provided by Puppet. + Returns the literal type when passed a value. Requires the new parser. Useful for comparison of types with `<=` such as in `if type_of($some_value) <= Array[String] { ... }` (which is equivalent to `if $some_value =~ Array[String] { ... }`) *Type*: rvalue. #### `union`