Skip to content

NumberRange

A numberRange is a data-type for storing a an evenly-spaced range of numbers. For example, a particular numberRange variable might hold the numbers:

1
2, 4, 6, 8, 10

This data-type is especially useful when used in combination with an iterator or when used to generate random numbers within a melody literal.


Syntax

To create a numberRange that has spacings of 1.0 between each number:

1
var myRange = between 30 to 35;

The example above would hold the following numbers:

1
30, 31, 32, 33, 34, 35

To create a numberRange that has custom spacing between each number:

1
var myRange = between 10 and 12 by 0.5;

The example above would hold the following numbers:

1
10, 10.5, 11, 11.5, 12

To create a numberRange that has a descending range (i.e. from big to small)

1
var myRange = between 5 and 0;

The example above would hold the following numbers:

1
5, 4, 3, 2, 1, 0

To delete a numberRange:

1
delete myRange;

Properties

A property is a special feature of a variable that can be used to get and/or set some aspect of that variable.

start

The start property can be used to find out the starting number for the range

1
var result = myRange.start;

end

The end property can be used to find out the ending number for the range

1
var result = myRange.end;

by

The by property can be used to find out the spacing between numbers in the range

1
var result = myRange.by;

type

The type property can be used to find out the data-type of a particular numberRange variable. The result will always be "numberRange"

1
var result = myRange.type;

Functions

There are no functions specific to numberRanges