- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Loop
i := 0;
while i < 10 {
	i++
}i := 10
do {
	i -= 2
} while (i > 0)YJLO Script provides a convenient for statement to loop through a block of code a number of times.
The for statement format is:
for [variable name] in [range] by [increment value] { 
	/* Clause */ 
}For example:
for i in 3...8 by 2 {
	print( i )
}OUTPUT:
3
5
7
[increment value] can be negative, and [range] should be a decreasing range in such case. For example,
for i in 5...3 by -1 {
	print( i )
}OUTPUT:
5
4
3
The by [increment value] part can be omitted, and the default increment value is 1.
for i in 5...8 {
	print( i )
}OUTPUT:
5
6
7
8
[range] can be half opened. Use ..< for half-open increasing range, and ..> for half-open decreasing range. For example,
for i in 5..<8 {
	print( i )
}OUTPUT:
5
6
7
Values in [range] and [increment value] can be any valid expression that is evaluated to a number.
a := 3;
for i in a..<a**2 by a-1 {
	print( i )
}OUTPUT:
3
5
7
In addition, looping through a list is as simple as:
for e in ['a', 'b', 'c'] {
	print(e)
}OUTPUT:
a
b
c
Similarly, you can also loop through an Array:
for e in Array(['a', 'b', 'c']) {
	print(e)
}The break statement "jumps out" of a loop.
a := 0
while true {
    if ++a > 3 {
        break
    }
    print( a )
}OUTPUT:
1
2
3
The continue statement "jumps over" one iteration in the loop.
for a in 0..<10 {
	if ++a % 2 == 0 {
		continue
	}
	print( a )
}OUTPUT:
1
3
5
7
9
Introduction
Langauge Guide
Libraries
- Utility
- ListUtil
- StringUtil
- Math
 
- Data Structure
- LinkedList
- Stack
- Heap
- HeapList
- HashMap
- HashSet
 
- Others
- UnitTest
- Tokenizer
 
Dev Reference
- Syntax Sugar