Skip to content

Commit d3bbd3c

Browse files
npwalkerDavidS
authored andcommitted
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.
1 parent cb59da2 commit d3bbd3c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,8 @@ Returns a string description of the type when passed a value. Type can be a stri
11901190

11911191
#### `type_of`
11921192

1193+
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.
1194+
11931195
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.
11941196

11951197
#### `union`

lib/puppet/functions/type_of.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# See the documentation for "The Puppet Type System" for more information about types.
1111
# See the `assert_type()` function for flexible ways to assert the type of a value.
1212
#
13+
# The built-in type() function in puppet is generally preferred over this function
14+
# this function is provided for backwards compatibility.
1315
Puppet::Functions.create_function(:type_of) do
1416
def type_of(value)
1517
Puppet::Pops::Types::TypeCalculator.infer_set(value)

0 commit comments

Comments
 (0)