Skip to content

Commit ea6297f

Browse files
committed
chore: tour fixes
1 parent a1b25a8 commit ea6297f

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

docs/topics/data-classes.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ data class User(val name: String, val age: Int)
1010

1111
The compiler automatically derives the following members from all properties declared in the primary constructor:
1212

13-
* `.equals()`/`.hashCode()` pair.
14-
* `.toString()` of the form `"User(name=John, age=42)"`.
15-
* [`.componentN()` functions](destructuring-declarations.md) corresponding to the properties in their order of declaration.
16-
* `.copy()` function (see below).
13+
* `equals()`/`hashCode()` pair.
14+
* `toString()` of the form `"User(name=John, age=42)"`.
15+
* [`componentN()` functions](destructuring-declarations.md) corresponding to the properties in their order of declaration.
16+
* `copy()` function (see below).
1717

1818
To ensure consistency and meaningful behavior of the generated code, data classes have to fulfill the following requirements:
1919

@@ -23,13 +23,13 @@ To ensure consistency and meaningful behavior of the generated code, data classe
2323

2424
Additionally, the generation of data class members follows these rules with regard to the members' inheritance:
2525

26-
* If there are explicit implementations of `.equals()`, `.hashCode()`, or `.toString()` in the data class body or
26+
* If there are explicit implementations of `equals()`, `hashCode()`, or `toString()` in the data class body or
2727
`final` implementations in a superclass, then these functions are not generated, and the existing
2828
implementations are used.
29-
* If a supertype has `.componentN()` functions that are `open` and return compatible types, the
29+
* If a supertype has `componentN()` functions that are `open` and return compatible types, the
3030
corresponding functions are generated for the data class and override those of the supertype. If the functions of the
3131
supertype cannot be overridden due to incompatible signatures or due to their being final, an error is reported.
32-
* Providing explicit implementations for the `.componentN()` and `.copy()` functions is not allowed.
32+
* Providing explicit implementations for the `componentN()` and `copy()` functions is not allowed.
3333

3434
Data classes may extend other classes (see [Sealed classes](sealed-classes.md) for examples).
3535

@@ -53,10 +53,10 @@ data class Person(val name: String) {
5353
}
5454
```
5555
56-
In the example below, only the `name` property is used by default inside the `.toString()`, `.equals()`, `.hashCode()`,
57-
and `.copy()` implementations, and there is only one component function, `.component1()`.
56+
In the example below, only the `name` property is used by default inside the `toString()`, `equals()`, `hashCode()`,
57+
and `copy()` implementations, and there is only one component function, `component1()`.
5858
The `age` property is declared inside the class body and is excluded.
59-
Therefore, two `Person` objects with the same `name` but different `age` values are considered equal since `.equals()`
59+
Therefore, two `Person` objects with the same `name` but different `age` values are considered equal since `equals()`
6060
only evaluates properties from the primary constructor:
6161

6262
```kotlin
@@ -85,7 +85,7 @@ fun main() {
8585

8686
## Copying
8787

88-
Use the `.copy()` function to copy an object, allowing you to alter _some_ of its properties while keeping the rest unchanged.
88+
Use the `copy()` function to copy an object, allowing you to alter _some_ of its properties while keeping the rest unchanged.
8989
The implementation of this function for the `User` class above would be as follows:
9090

9191
```kotlin

docs/topics/gradle/gradle-configure-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ In the following table, there are the minimum and maximum **fully supported** ve
6060
| 1.7.0–1.7.10 | 6.7.1–7.0.2 | 3.4.3–7.0.2 |
6161
| 1.6.20–1.6.21 | 6.1.1–7.0.2 | 3.4.3–7.0.2 |
6262

63-
> Kotlin 2.0.20 is fully compatible with Gradle 6.8.3 through 8.6.
63+
> *Kotlin 2.0.20 is fully compatible with Gradle 6.8.3 through 8.6.
6464
> Gradle 8.7 and 8.8 are also supported, with only one exception: If you use the Kotlin Multiplatform Gradle plugin,
6565
> you may see deprecation warnings in your multiplatform projects calling the [`withJava()` function in the JVM target](multiplatform-dsl-reference.md#jvm-targets).
6666
> For more information, see the issue in [YouTrack](https://youtrack.jetbrains.com/issue/KT-66542/Gradle-JVM-target-with-withJava-produces-a-deprecation-warning).

docs/topics/tour/kotlin-tour-classes.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ data class User(val name: String, val id: Int)
151151

152152
The most useful predefined member functions of data classes are:
153153

154-
| **Function** | **Description** |
155-
|---------------------|----------------------------------------------------------------------------------------------------------------|
156-
| `.toString()` | Prints a readable string of the class instance and its properties. |
157-
| `.equals()` or `==` | Compares instances of a class. |
158-
| `.copy()` | Creates a class instance by copying another, potentially with some different properties. |
154+
| **Function** | **Description** |
155+
|--------------------|------------------------------------------------------------------------------------------|
156+
| `toString()` | Prints a readable string of the class instance and its properties. |
157+
| `equals()` or `==` | Compares instances of a class. |
158+
| `copy()` | Creates a class instance by copying another, potentially with some different properties. |
159159

160160
See the following sections for examples of how to use each function:
161161

@@ -165,8 +165,8 @@ See the following sections for examples of how to use each function:
165165

166166
### Print as string
167167

168-
To print a readable string of a class instance, you can explicitly call the `.toString()` function, or use print functions
169-
(`println()` and `print()`) which automatically call `.toString()` for you:
168+
To print a readable string of a class instance, you can explicitly call the `toString()` function, or use print functions
169+
(`println()` and `print()`) which automatically call `toString()` for you:
170170

171171
```kotlin
172172
data class User(val name: String, val id: Int)
@@ -212,9 +212,9 @@ fun main() {
212212

213213
### Copy instance
214214

215-
To create an exact copy of a data class instance, call the `.copy()` function on the instance.
215+
To create an exact copy of a data class instance, call the `copy()` function on the instance.
216216

217-
To create a copy of a data class instance **and** change some properties, call the `.copy()` function on the instance
217+
To create a copy of a data class instance **and** change some properties, call the `copy()` function on the instance
218218
**and** add replacement values for properties as function parameters.
219219

220220
For example:
@@ -329,7 +329,7 @@ a fixed list of potential names (inside the class body). Configure the class wit
329329
the class header). In the class body, define the `generateEmployee()` function. Once again, the main function demonstrates
330330
how you can use this class.
331331

332-
> In this exercise, you import a package so that you can use the `Random.nextInt()` function.
332+
> In this exercise, you import a package so that you can use the [`Random.nextInt()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.random/-random/next-int.html) function.
333333
> For more information about importing packages, see [Packages and imports](packages.md).
334334
>
335335
{type = "tip"}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ fun main() {
238238

239239
### Exercise 2 {initial-collapse-state="collapsed" id="conditional-expressions-exercise-2"}
240240

241-
Using a `when` expression, update the following program so that when you input the names of GameBoy buttons, the actions
242-
are printed as output.
241+
Using a `when` expression, update the following program so that it prints the corresponding actions when you input the
242+
names of game console buttons.
243243

244244
| **Button** | **Action** |
245245
|------------|------------------------|

docs/topics/whatsnew2020.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ receivers feature.
2929

3030
### Data class copy function to have the same visibility as constructor
3131

32-
Currently, if you create a data class using a `private` constructor, the automatically generated `.copy()` function doesn't
32+
Currently, if you create a data class using a `private` constructor, the automatically generated `copy()` function doesn't
3333
have the same visibility. This can cause problems later in your code. In future Kotlin releases, we will introduce the
34-
behavior that the default visibility of the `.copy()` function is the same as the constructor. This change will be
34+
behavior that the default visibility of the `copy()` function is the same as the constructor. This change will be
3535
introduced gradually to help you migrate your code as smoothly as possible.
3636

3737
Our migration plan starts with Kotlin 2.0.20, which issues warnings in your code where the visibility will
@@ -60,7 +60,7 @@ To give you more control over this behavior, in Kotlin 2.0.20 we've introduced t
6060

6161
* `@ConsistentCopyVisibility` to opt in to the behavior now before we make it the default in a later release.
6262
* `@ExposedCopyVisibility` to opt out of the behavior and suppress warnings at the declaration site.
63-
Note that even with this annotation, the compiler still reports warnings when the `.copy()` function is called.
63+
Note that even with this annotation, the compiler still reports warnings when the `copy()` function is called.
6464

6565
If you want to opt in to the new behavior already in 2.0.20 for a whole module rather than in individual classes,
6666
you can use the `-Xconsistent-data-class-copy-visibility` compiler option.

0 commit comments

Comments
 (0)