Skip to content

Commit eb999e7

Browse files
alcarrazsarahhaggarty
authored andcommitted
Move conditional expressions and ranges practice section
Conditional expressions and ranges practice, is only about conditional expressions, so it is better placed nearer to Conditional expressions. Also, ranges is more suitable to be practiced with loops, so it would make more sense to group it with it, or to have its own practice section.
1 parent 4b485f8 commit eb999e7

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

docs/topics/tour/kotlin-tour-control-flow.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,7 @@ Using `when` with a subject makes your code easier to read and maintain. When yo
175175
it also helps Kotlin check that all possible cases are covered. Otherwise, if you don't use a subject with a
176176
`when` expression, you need to provide an else branch.
177177

178-
## Ranges
179-
180-
Before talking about loops, it's useful to know how to construct ranges for loops to iterate over.
181-
182-
The most common way to create a range in Kotlin is to use the `..` operator. For example, `1..4` is equivalent to `1, 2, 3, 4`.
183-
184-
To declare a range that doesn't include the end value, use the `..<` operator. For example, `1..<4` is equivalent to `1, 2, 3`.
185-
186-
To declare a range in reverse order, use `downTo.` For example, `4 downTo 1` is equivalent to `4, 3, 2, 1`.
187-
188-
To declare a range that increments in a step that isn't 1, use `step` and your desired increment value.
189-
For example, `1..5 step 2` is equivalent to `1, 3, 5`.
190-
191-
You can also do the same with `Char` ranges:
192-
193-
* `'a'..'d'` is equivalent to `'a', 'b', 'c', 'd'`
194-
* `'z' downTo 's' step 2` is equivalent to `'z', 'x', 'v', 't'`
195-
196-
## Conditional expressions and ranges practice
178+
## Conditional expressions practice
197179

198180
### Exercise 1 {initial-collapse-state="collapsed" collapsible="true" id="conditional-expressions-exercise-1"}
199181

@@ -281,6 +263,24 @@ fun main() {
281263
```
282264
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-control-flow-conditional-solution-2"}
283265

266+
## Ranges
267+
268+
Before talking about loops, it's useful to know how to construct ranges for loops to iterate over.
269+
270+
The most common way to create a range in Kotlin is to use the `..` operator. For example, `1..4` is equivalent to `1, 2, 3, 4`.
271+
272+
To declare a range that doesn't include the end value, use the `..<` operator. For example, `1..<4` is equivalent to `1, 2, 3`.
273+
274+
To declare a range in reverse order, use `downTo.` For example, `4 downTo 1` is equivalent to `4, 3, 2, 1`.
275+
276+
To declare a range that increments in a step that isn't 1, use `step` and your desired increment value.
277+
For example, `1..5 step 2` is equivalent to `1, 3, 5`.
278+
279+
You can also do the same with `Char` ranges:
280+
281+
* `'a'..'d'` is equivalent to `'a', 'b', 'c', 'd'`
282+
* `'z' downTo 's' step 2` is equivalent to `'z', 'x', 'v', 't'`
283+
284284
## Loops
285285

286286
The two most common loop structures in programming are `for` and `while`. Use `for` to iterate over a range of

0 commit comments

Comments
 (0)