Number Range

ASnake Documentation

Table Of Contents

Summary:

A syntax shortcut for creating a range between two numbers. In the compiled code will transform into a range function, such as range(1,12).

Warning: this feature may be reworked, particularly removing ..., switching .. to act like ..., and allowing whitespace. Though it is not fully decided yet.

Syntax x...y:

Variable (which is an integer) or literal integer followed by three periods and then a variable (which is an integer) or literal integer.

Whitespace must not be present.

First argument is start, last argument is end.

This will create a simple range between those two values.

puts does print z ,end='' from z

int y = 4

for x in 1...y do puts x
# result: 123

This will start at the number you specified, and as per how Python's range function works, will stop one iteration before the end number is reached.

This has an alias of to, but only when literal integers are specified.

puts does print z ,end='' from z

for x in 1 to 5 do puts x
# result: 1234

Syntax x..y:

Works exactly the same as ..., except will attempt to add one integer to the end argument. May be less confusing for some people.

puts does print z ,end='' from z

for x in 1..5 do puts x
# result: 12345
Scroll to top