Range

A Range represents a sequence of numbers, with a start and end, and optionally a given step.

let one_to_five be new Range with 1, and 6

Ranges serve as Iterables to use in for each loops.

let one_to_six be Range's inclusive with 1, and 6

for each number in one_to_six do
  print number # 1, 2, 3, 4, 5, 6

Sparkle supports special syntax to easily create ranges, inspired by Scala.

let range_a be 1 until 5       # 1, 2, 3, 4
let range_b be 1 to 5          # 1, 2, 3, 4, 5
let range_c be 0 to 100 by 20  # 0, 20, 40, 60, 80, 100

Static Functions

Returns a new Range from start to end, inclusive. The arguments must all be of the same type.

Constructor

Creates a new Range from start to end, non-inclusive. The arguments must all be of the same type.

Getters

A getter that returns an Iterator to iterate over the list elements.

print "hello world"