Skip to content

Commit 1a89f7a

Browse files
committed
chore: update stable links in whatsnew22.md
1 parent 8c00976 commit 1a89f7a

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

docs/topics/control-flow.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ fun main() {
356356
The scope of a variable introduced as the subject is restricted to the body of the `when` expression or statement.
357357

358358
### Guard conditions {id="guard-conditions-in-when-expressions"}
359-
<primary-label ref="experimental-general"/>
360359

361360
Guard conditions allow you to include more than one condition to the branches of a `when` expression or statement, making complex
362361
control flow more explicit and concise. You can use guard conditions with `when` as long as it has a subject.
@@ -369,6 +368,10 @@ sealed interface Animal {
369368
data class Dog(val breed: String) : Animal
370369
}
371370

371+
fun feedDog() = println("Feeding a dog")
372+
fun feedCat() = println("Feeding a cat")
373+
374+
//sampleStart
372375
fun feedAnimal(animal: Animal) {
373376
when (animal) {
374377
// Branch with only primary condition
@@ -394,7 +397,9 @@ fun main() {
394397
// Feeding a cat
395398
// Unknown animal
396399
}
400+
//sampleEnd
397401
```
402+
{kotlin-runnable="true" kotlin-min-compiler-version="2.2" id="kotlin-when-guard-conditions"}
398403

399404
You can't use guard conditions when you have multiple conditions separated by a comma. For example:
400405

@@ -436,20 +441,6 @@ when (animal) {
436441
}
437442
```
438443

439-
> To enable guard conditions in CLI, run the following command:
440-
>
441-
> `kotlinc -Xwhen-guards main.kt`
442-
>
443-
> To enable guard conditions in Gradle, add the following line to your `build.gradle.kts` file:
444-
>
445-
> `kotlin.compilerOptions.freeCompilerArgs.add("-Xwhen-guards")`
446-
>
447-
{style="note"}
448-
449-
#### Leave feedback
450-
451-
We would appreciate your feedback on guard conditions in [YouTrack](https://youtrack.jetbrains.com/issue/KT-71140/Guard-conditions-in-when-expressions-feedback).
452-
453444
## For loops
454445

455446
Use the `for` loop to iterate through a [collection](collections-overview.md), [array](arrays.md), or [range](ranges.md):

docs/topics/whatsnew/whatsnew22.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ In Kotlin 2.1.0, several new language features were introduced in preview.
385385
We're happy to announce that the following language features are now
386386
[Stable](components-stability.md#stability-levels-explained) in this release:
387387

388-
* [Guard conditions in `when` with a subject](whatsnew21.md#guard-conditions-in-when-with-a-subject)
389-
* [Non-local `break` and `continue`](whatsnew21.md#non-local-break-and-continue)
390-
* [Multi-dollar interpolation: improved handling of `$` in string literals](whatsnew21.md#multi-dollar-string-interpolation)
388+
* [Guard conditions in `when` with a subject](control-flow.md#guard-conditions-in-when-expressions)
389+
* [Non-local `break` and `continue`](inline-functions.md#break-and-continue)
390+
* [Multi-dollar interpolation: improved handling of `$` in string literals](strings.md#multi-dollar-string-interpolation)
391391

392392
[See the full list of Kotlin language design features and proposals](kotlin-language-features-and-proposals.md).
393393

0 commit comments

Comments
 (0)