Skip to content

Commit 477561f

Browse files
committed
docs: revised according to review.
1 parent 4a049b0 commit 477561f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

examples/02_control_flow/01_When.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# When
22

3-
Instead of widely used `switch` statement, Kotlin provides the more flexible and clear `when` construction. It can be used either as a statement or as an expression.
3+
Instead of the widely used `switch` statement, Kotlin provides the more flexible and clear `when` construction. It can be used either as a statement or as an expression.
44

55
## When Statement
66

@@ -31,10 +31,10 @@ class MyClass
3131
</div>
3232

3333
1. This is a `when` statement.
34-
2. Checking whether `obj` equals to one.
35-
3. Checking whether `obj` equals to `Hello`.
36-
4. Type checking.
37-
5. Inverse type checking.
34+
2. Checks whether `obj` equals to one.
35+
3. Checks whether `obj` equals to `Hello`.
36+
4. Performs type checking.
37+
5. Performs inverse type checking.
3838
6. Default statement (might be omitted).
3939

4040
Note that all branch conditions are checked sequentially until one of them is satisfied. So, only the first suitable branch will be executed.
@@ -65,7 +65,7 @@ fun whenAssign(obj: Any): Any {
6565
</div>
6666

6767
1. This is a `when` expression.
68-
2. Setting the value to `"one"` if `obj` equals to one.
69-
3. Setting the value to one if `obj` equals to `Hello`.
70-
4. Setting the value to `false` if `obj` is an instance of `Long`.
71-
5. Setting the value "42" if none of the previous conditions are satisfied. Unlike in `when` _statement_, the default branch is usually required in `when` _expression_, except the case when the compiler can check that other branches cover all possible cases.
68+
2. Sets the value to `"one"` if `obj` equals to one.
69+
3. Sets the value to one if `obj` equals to `Hello`.
70+
4. Sets the value to `false` if `obj` is an instance of `Long`.
71+
5. Sets the value "42" if none of the previous conditions are satisfied. Unlike in `when` _statement_, the default branch is usually required in `when` _expression_, except the case when the compiler can check that other branches cover all possible cases.

examples/02_control_flow/02_Loops.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fun main(args: Array<String>) {
2323

2424
</div>
2525

26-
1. Looping through each cake in the list.
26+
1. Loops through each cake in the list.
2727

2828
### `while` and `do-while`
2929

@@ -54,12 +54,12 @@ fun main(args: Array<String>) {
5454

5555
</div>
5656

57-
1. Executing the block while the condition is true.
58-
2. Executing the block first and then checking the condition.
57+
1. Executes the block while the condition is true.
58+
2. Executes the block first and then checking the condition.
5959

6060
### Iterators
6161

62-
You can define own iterators in your classes by implementing the `iterator` operator in them.
62+
You can define your own iterators in your classes by implementing the `iterator` operator in them.
6363

6464
<div class="language-kotlin" theme="idea" data-min-compiler-version="1.3">
6565

@@ -86,10 +86,10 @@ fun main() {
8686

8787
</div>
8888

89-
1. Defining an iterator in a class. It must be named `iterator` and have the `operator` modifier.
90-
2. Returning the iterator that meets the following method requirements:
89+
1. Defines an iterator in a class. It must be named `iterator` and have the `operator` modifier.
90+
2. Returns the iterator that meets the following method requirements:
9191
* `next()`: `Animal`
9292
* `hasNext()`: `Boolean`
93-
3. Looping through animals in the zoo with the user-defined iterator.
93+
3. Loops through animals in the zoo with the user-defined iterator.
9494

9595
The iterator can be declared in the type or as an extension function.

examples/02_control_flow/03_Ranges.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ fun main() {
2828

2929
</div>
3030

31-
1. Iterating over a range starting from 0 up to 3 (inclusive).
32-
2. Iterating over a range with a custom increment step for consecutive elements.
33-
5. Iterating over a range in _reverse_ order.
31+
1. Iterates over a range starting from 0 up to 3 (inclusive).
32+
2. Iterates over a range with a custom increment step for consecutive elements.
33+
5. Iterates over a range in _reverse_ order.
3434

3535
Char ranges are also supported:
3636

@@ -55,7 +55,7 @@ fun main() {
5555

5656
</div>
5757

58-
1. Iterating over a char range in alphabetical order.
58+
1. Iterates over a char range in alphabetical order.
5959
2. Char ranges support `step` and `downTo` as well.
6060

6161
Ranges are also useful in `if` statements:
@@ -80,5 +80,5 @@ fun main() {
8080

8181
</div>
8282

83-
1. Checking if a value is in the range.
83+
1. Checks if a value is in the range.
8484
2. `!in` is the opposite of `in`.

examples/02_control_flow/05_Conditional expression.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ fun main() {
1616

1717
</div>
1818

19-
1. `if` is an expression here, i.e. it returns a value.
19+
1. `if` is an expression here: it returns a value.

0 commit comments

Comments
 (0)