Skip to content

Commit aa98e52

Browse files
committed
docs: revised according to review.
1 parent 664a721 commit aa98e52

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

examples/03_special_classes/01_Data classes.md

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

3-
[Data classes](https://kotlinlang.org/docs/reference/data-classes.html) make it easy to create classes that are used to store some values. Such classes are automatically provided with methods for copying, getting a string representation, and using instances in collections.
3+
[Data classes](https://kotlinlang.org/docs/reference/data-classes.html) make it easy to create classes that are used to store values. Such classes are automatically provided with methods for copying, getting a string representation, and using instances in collections.
44

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

@@ -32,7 +32,7 @@ fun main() {
3232

3333
</div>
3434

35-
1. Defining a data class with the `data` modifier.
35+
1. Defines a data class with the `data` modifier.
3636
2. Method `toString` is auto-generated, which makes `println` output look nice.
3737
3. Auto-generated `equals` considers two instances equal if all their properties are equal.
3838
4. Equal data class instances have equal `hashCode()`.

examples/03_special_classes/02_Enum.md

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

3-
[Enum classes](https://kotlinlang.org/docs/reference/enum-classes.html) are used to model types that represent a finite set of distinct values, such as directions, states, modes and so forth.
3+
[Enum classes](https://kotlinlang.org/docs/reference/enum-classes.html) are used to model types that represent a finite set of distinct values, such as directions, states, modes, and so forth.
44

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

@@ -23,8 +23,8 @@ fun main() {
2323

2424
</div>
2525

26-
1. Defining a simple enum class with three enum instances. The number of instances is always finite and they are all distinct.
27-
2. Accessing an enum instance via the class name.
26+
1. Defines a simple enum class with three enum instances. The number of instances is always finite and they are all distinct.
27+
2. Accesses an enum instance via the class name.
2828
3. With enums, the compiler can infer if a `when`-expression is exhaustive so that you don't need the `else`-case.
2929

3030
Enums may contain properties and methods like other classes, separated from the list of instances by a semicolon.
@@ -53,9 +53,9 @@ fun main() {
5353

5454
</div>
5555

56-
1. Defining an enum class with a property and a method.
56+
1. Defines an enum class with a property and a method.
5757
2. Each instance must pass an argument for the constructor parameter.
5858
3. Enum class members are separated from the instance definitions by a semicolon.
5959
4. The default `toString` returns the name of the instance, here `"RED"`.
60-
5. Calling a method on a enum instance.
61-
6. Calling a method via enum class name.
60+
5. Calls a method on a enum instance.
61+
6. Calls a method via enum class name.

examples/03_special_classes/03_Sealed Classes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ fun main() {
2525
</div>
2626

2727

28-
1. Defining a sealed class.
29-
2. Defining subclasses. Note that all subclasses must be in the same file.
30-
3. Using an instance of the sealed class as an argument in a `when` expression.
28+
1. Defines a sealed class.
29+
2. Defines subclasses. Note that all subclasses must be in the same file.
30+
3. Uses an instance of the sealed class as an argument in a `when` expression.
3131
4. A smartcast is performed, casting `Mammal` to `Human`.
3232
5. A smartcast is performed, casting `Mammal` to `Cat`.
3333
6. The `else`-case is not necessary here since all possible subclasses of the sealed class are covered. With a non-sealed superclass `else` would be required.

examples/03_special_classes/04_Object.md

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

3-
Classes and objects in Kotlinwork the same way as in most object-oriented languages: a *class* is a blueprint, and an *object* is an instance of a class. Usually, you define a class and then create multiple instances of that class:
3+
Classes and objects in Kotlin work the same way as in most object-oriented languages: a *class* is a blueprint, and an *object* is an instance of a class. Usually, you define a class and then create multiple instances of that class:
44

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

@@ -25,12 +25,12 @@ fun main() {
2525

2626
</div>
2727

28-
1. Defining a blueprint.
29-
2. Defining a method.
30-
3. Creating instances.
31-
4. Calling the method on instances.
28+
1. Defines a blueprint.
29+
2. Defines a method.
30+
3. Creates instances.
31+
4. Calls the method on instances.
3232

33-
In Kotlin you also have also the [**object** keyword](https://kotlinlang.org/docs/reference/object-declarations.html). It is used to obtain a *data type with a single implementation*.
33+
In Kotlin you also have the [**object** keyword](https://kotlinlang.org/docs/reference/object-declarations.html). It is used to obtain a *data type with a single implementation*.
3434

3535
If you are a Java user and want to understand what "*single*" means, you can think of the **Singleton** pattern:
3636
it ensures you that only one instance of that class is created even if 2 threads try to create it.
@@ -40,8 +40,8 @@ Why lazy? Because it will be created once when the object is accessed. Otherwise
4040

4141
### `object` Expression
4242

43-
Here is a typical basic usage of an `object` **expression**: a simple object/properties structure.
44-
There is no need in class declaration: you create a single object, declare its members and access it within one function.
43+
Here is a basic typical usage of an `object` **expression**: a simple object/properties structure.
44+
There is no need to do so in class declaration: you create a single object, declare its members and access it within one function.
4545
Objects like this are often created in Java as anonymous class instances.
4646

4747
<div class="language-kotlin" theme="idea" data-min-compiler-version="1.3">
@@ -68,11 +68,11 @@ fun main() {
6868

6969
</div>
7070

71-
1. Creating a function with parameters.
72-
2. Creating an object to use when calculating the result value.
73-
3. Accessing the object's properties.
74-
4. Printing the result.
75-
5. Calling the function. This is when the object is actually created.
71+
1. Creates a function with parameters.
72+
2. Creates an object to use when calculating the result value.
73+
3. Accesses the object's properties.
74+
4. Prints the result.
75+
5. Calls the function. This is when the object is actually created.
7676

7777
### `object` Declaration
7878

@@ -95,9 +95,9 @@ fun main(){
9595

9696
</div>
9797

98-
1. Creating an object declaration.
99-
2. Defining the object method.
100-
3. Calling the method. This is when the object is actually created.
98+
1. Creates an object declaration.
99+
2. Defines the object method.
100+
3. Calls the method. This is when the object is actually created.
101101

102102
### Companion Objects
103103

@@ -125,7 +125,7 @@ fun main() {
125125

126126
</div>
127127

128-
1. Defininfg a class.
129-
2. Defining a companion. Its name can be omitted.
130-
3. Defining a companion object method.
131-
4. Calling the companion object method via the class name.
128+
1. Defines a class.
129+
2. Defines a companion. Its name can be omitted.
130+
3. Defines a companion object method.
131+
4. Calls the companion object method via the class name.

0 commit comments

Comments
 (0)