arrayRange

Build an array out of a range of numbers or using our range syntax: {start}..{end} or using the from and to arguments

arrayRange(from, to) → returns numeric

Member Function Syntax

This function requires BoxLang 1.0.0 and up.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

from numeric
Required
Default: 1

The initial index, defaults to 1 or you can use the {start}..{end} notation.

to numeric
Required

The last index item, or defaults to the from value.

Examples
Sample code invoking the arrayRange function

arr = arrayRange( "2..5" );
writeOutput('This array has ' & arrayLen(arr) & ' elements.');

Expected Result: This array has 4 elements.

arr = arrayRange( 5, 10 );
writeOutput('This array has ' & arrayLen(arr) & ' elements.');

Expected Result: This array has 6 elements.

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub