diff --git a/examples/02_control_flow/03_Ranges.md b/examples/02_control_flow/03_Ranges.md index 2246e83..5636a84 100755 --- a/examples/02_control_flow/03_Ranges.md +++ b/examples/02_control_flow/03_Ranges.md @@ -15,12 +15,17 @@ fun main() { } print(" ") - for(i in 2..8 step 2) { // 3 + for(i in 0..<3) { // 3 print(i) } print(" ") - for (i in 3 downTo 0) { // 4 + for(i in 2..8 step 2) { // 4 + print(i) + } + print(" ") + + for (i in 3 downTo 0) { // 5 print(i) } print(" ") @@ -31,8 +36,9 @@ fun main() { 1. Iterates over a range starting from 0 up to 3 (inclusive). Like 'for(i=0; i<=3; ++i)' in other programming languages (C/C++/Java). 2. Iterates over a range starting from 0 up to 3 (exclusive). Like for loop in Python or like 'for(i=0; i<3; ++i)' in other programming languages (C/C++/Java). -3. Iterates over a range with a custom increment step for consecutive elements. -4. Iterates over a range in _reverse_ order. +3. Iterates over a range starting from 0 up to 3 (exclusive). This syntax equals to '0 until 3', which is better understood. (available in version 1.9.0) +4. Iterates over a range with a custom increment step for consecutive elements. +5. Iterates over a range in _reverse_ order. Char ranges are also supported: