Deprecate `:` operator in `FOR` statement, add `..` and `..=` operators instead
Sayakie opened this issue ยท 0 comments
Currently we can use the :
operator for looping with FOR
statement:
FOR count = 0:3
realCount = 3 - count
#MESSAGE realCount
#WAIT 1
ENDFOR
#MESSAGE "BOOM"
but I suggest add the ..
and ..=
operators to use as a more readable equivalent to the traditional for-loop operating over a range of values.
The difference between ..
and ..=
operators is end will be exclusive or inclusive.
Examples
FOR i = 3..0
#MESSAGE i
ENDFOR
// Prints
// >> 3
// >> 2
// >> 1
Yeah, as you can see above we can use reverse order iteration!
FOR i = 2..=7
#MESSAGE i
ENDFOR
// Prints
// >> 2
// >> 3
// >> 4
// >> 5
// >> 6
// >> 7
Another example shows "7" also can be displayed.