From ef935bb287c54ac615f7f538a6f89190b4d2c4d7 Mon Sep 17 00:00:00 2001 From: tphoney Date: Tue, 19 Jul 2016 11:42:47 +0100 Subject: (MODULES-2143) document edge behaviour of range. --- README.markdown | 1 + lib/puppet/parser/functions/range.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index f176d98..45b4482 100644 --- a/README.markdown +++ b/README.markdown @@ -881,6 +881,7 @@ The third argument to this function is the salt to use. Extrapolates a range as an array when given in the form of '(start, stop)'. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9]. Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"]. +NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail. Passing a third argument will cause the generated range to step by that interval, e.g. `range("0", "9", "2")` returns ["0","2","4","6","8"]. diff --git a/lib/puppet/parser/functions/range.rb b/lib/puppet/parser/functions/range.rb index 2fc2113..d690df7 100644 --- a/lib/puppet/parser/functions/range.rb +++ b/lib/puppet/parser/functions/range.rb @@ -25,8 +25,8 @@ integers automatically) Will return: ["a","b","c"] range("host01", "host10") - Will return: ["host01", "host02", ..., "host09", "host10"] +NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail. Passing a third argument will cause the generated range to step by that interval, e.g. -- cgit v1.2.3