From d3bbd3cbf89cb23bce4e55c3828e17c05c4cfd70 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Thu, 1 Dec 2016 05:54:08 -0800 Subject: Indicate that the type function is preferred (#695) 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. --- README.markdown | 2 ++ lib/puppet/functions/type_of.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 3e937b1..a6b7bda 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` diff --git a/lib/puppet/functions/type_of.rb b/lib/puppet/functions/type_of.rb index 02cdd4d..01f1f49 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) -- cgit v1.2.3