Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
LiYing2010 committed Mar 21, 2024
1 parent 3f823d0 commit 75d91d8
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 20 deletions.
2 changes: 1 addition & 1 deletion data/_nav_zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ reference:
- url: /docs/reference_zh/whatsnew19.html
title: Kotlin 1.9.0
- url: /docs/reference_zh/whatsnew-eap.html
title: Kotlin 2.0.0-Beta4
title: Kotlin 2.0.0-Beta5
- title: 早期版本
content:
- url: /docs/reference_zh/whatsnew1820.html
Expand Down
8 changes: 4 additions & 4 deletions data/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ latest:
coroutines:
version: 1.7.3

latestDocDate: 2024/03/13
latestDocDate: 2024/03/21

kotlinEapVersion: 2.0.0-Beta4
kotlinEapReleaseDate: 2024/02/13
kotlinEapVersion: 2.0.0-Beta5
kotlinEapReleaseDate: 2024/03/20

coroutinesEapVersion: 1.7.3

Expand Down Expand Up @@ -45,7 +45,7 @@ dateTimeVersion: 0.4.0

foojayResolver: 0.5.0

lincheckVersion: 2.26
lincheckVersion: 2.28
jctoolsVersion: 3.3.0

lombokVersion: 1.18.22
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/reference_zh/all-open-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Kotlin 为 `all-open` 插件提供了 Gradle 和 Maven 支持, 并带有完整

```kotlin
plugins {
id("org.jetbrains.kotlin.plugin.allopen") version "{{ site.data.releases.latest.version }}"
kotlin("plugin.allopen") version "{{ site.data.releases.latest.version }}"
}
```

Expand Down
3 changes: 2 additions & 1 deletion pages/docs/reference_zh/cross-platform-frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Flutter 拥有遍及全世界、相对活跃的用户社区, 并被很多开发

**编程语言:** JavaScript.

**移动应用程序示例:** Skype, Bloomberg, Shopify, [Facebook 和 Instagram](https://itcraftapps.com/blog/7-react-native-myths-vs-reality/#facebook-instagram-in-react-native) 中的很多小模块.
**移动应用程序示例:** React Native 被应用于 Microsoft 公司的 Office, Skype, 以及 Xbox Game Pass; Meta 公司的 Facebook, Desktop Messenger, 以及 Oculus.
更多案例请参见 [React Native 案例展示](https://reactnative.dev/showcase).

**主要功能特性:**

Expand Down
7 changes: 4 additions & 3 deletions pages/docs/reference_zh/eap.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ title: "参加 Kotlin EAP 项目"
<th>重要功能</th>
</tr>
<tr>
<td><strong>2.0.0-Beta4</strong>
<p>发布日期: <strong>2024/02/13</strong></p>
<td><strong>2.0.0-Beta5</strong>
<p>发布日期: <strong>2024/03/20</strong></p>
<p><a href="https://github.com/JetBrains/kotlin/releases/tag/v2.0.0-Beta4" target="_blank">GitHub 上的 Release 页面</a></p>
</td>
<td>
<p>Kotlin K2 编译器的稳定发布版.</p>
<p>包括 Gradle 构建工具的改进.</p>
<p>更多详情, 请参见 <a href="https://github.com/JetBrains/kotlin/releases/tag/v2.0.0-Beta4">changelog</a> 或 <a href="whatsnew-eap.html">Kotlin 2.0.0-Beta4 中的新功能</a>.</p>
<p>Kotlin/Wasm 与 JavaScript 交互能力的改进.</p>
<p>更多详情, 请参见 <a href="https://github.com/JetBrains/kotlin/releases/tag/v2.0.0-Beta5">changelog</a> 或 <a href="whatsnew-eap.html">Kotlin 2.0.0-Beta5 中的新功能</a>.</p>
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/reference_zh/gradle/gradle-configure-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ plugins {

| KGP 版本 | Gradle 最低和最高版本 | AGP 最低和最高版本 |
|---------------|---------------------------------------|-----------------------------------------------------|
| 1.9.20 | {{ site.data.releases.minGradleVersion }}–{{ site.data.releases.maxGradleVersion }} | {{ site.data.releases.minAndroidGradleVersion }}–{{ site.data.releases.maxAndroidGradleVersion }} |
| 1.9.20–1.9.23 | {{ site.data.releases.minGradleVersion }}–{{ site.data.releases.maxGradleVersion }} | {{ site.data.releases.minAndroidGradleVersion }}–{{ site.data.releases.maxAndroidGradleVersion }} |
| 1.9.0–1.9.10 | 6.8.3–7.6.0 | 4.2.2–7.4.0 |
| 1.8.20–1.8.22 | 6.8.3–7.6.0 | 4.1.3–7.4.0 |
| 1.8.0–1.8.11 | 6.8.3–7.3.3 | 4.1.3–7.2.1 |
Expand Down
35 changes: 32 additions & 3 deletions pages/docs/reference_zh/iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ fun main() {
val numbersIterator = numbers.iterator()
while (numbersIterator.hasNext()) {
println(numbersIterator.next())
// 输出结果为
// one
// two
// three
// four
}
//sampleEnd
}
Expand All @@ -55,6 +60,11 @@ fun main() {
val numbers = listOf("one", "two", "three", "four")
for (item in numbers) {
println(item)
// 输出结果为
// one
// two
// three
// four
}
//sampleEnd
}
Expand All @@ -73,6 +83,11 @@ fun main() {
val numbers = listOf("one", "two", "three", "four")
numbers.forEach {
println(it)
// 输出结果为
// one
// two
// three
// four
}
//sampleEnd
}
Expand Down Expand Up @@ -106,9 +121,15 @@ fun main() {
val listIterator = numbers.listIterator()
while (listIterator.hasNext()) listIterator.next()
println("Iterating backwards:")
// 反向遍历:
while (listIterator.hasPrevious()) {
print("Index: ${listIterator.previousIndex()}")
println(", value: ${listIterator.previous()}")
// 输出结果为
// Index: 3, value: four
// Index: 2, value: three
// Index: 1, value: two
// Index: 0, value: one
}
//sampleEnd
}
Expand All @@ -135,16 +156,21 @@ fun main() {
val mutableIterator = numbers.iterator()

mutableIterator.next()
mutableIterator.remove()
mutableIterator.remove()
println("After removal: $numbers")
// 输出结果为
// After removal: [two, three, four]
//sampleEnd
}
```
</div>

对于可变的 list, 可以使用
[`MutableListIterator`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list-iterator/index.html).
除了删除元素之外, 这个迭代器还可以在遍历 list 的过程中添加元素, 或替换元素.
除了删除元素之外, 这个迭代器还可以在遍历 list 的过程中,
使用 [`add()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list-iterator/add.html)
[`set()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list-iterator/set.html) 函数,
添加或替换元素.

<div class="sample" markdown="1" theme="idea" data-min-compiler-version="1.3">

Expand All @@ -157,9 +183,12 @@ fun main() {

mutableListIterator.next()
mutableListIterator.add("two")
println(numbers)
// 输出结果为 [one, two, four, four]
mutableListIterator.next()
mutableListIterator.set("three")
mutableListIterator.set("three")
println(numbers)
// 输出结果为 [one, two, three, four]
//sampleEnd
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ actual enum class Department { IT, HR, Sales, Marketing }
fun matchOnDepartment(dept: Department) {
when (dept) {
Department.IT -> println("The IT Department")
Department.HR -> println("The IT Department")
Department.Sales -> println("The IT Department")
Department.HR -> println("The HR Department")
Department.Sales -> println("The Sales Department")
else -> println("Some other department")
}
}
Expand Down
23 changes: 21 additions & 2 deletions pages/docs/reference_zh/sam-with-receiver-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,34 @@ fun test(context: TaskContext) {

## Gradle

使用方法与 [all-open](all-open-plugin.html)插件 和 [no-arg](no-arg-plugin.html)插件相同,
使用方法与 [all-open](all-open-plugin.html) 插件和 [no-arg](no-arg-plugin.html) 插件相同,
区别是 sam-with-receiver 没有任何预定义, 因此你需要自己指定需要特别处理的注解.

<div class="multi-language-sample" data-lang="kotlin">
<div class="sample" markdown="1" mode="kotlin" theme="idea" data-lang="kotlin" data-highlight-only>

```kotlin
plugins {
kotlin("plugin.sam.with.receiver") version "{{ site.data.releases.latest.version }}"
}
```

</div>
</div>

<div class="multi-language-sample" data-lang="groovy">
<div class="sample" markdown="1" mode="groovy" theme="idea" data-lang="groovy">

```groovy
plugins {
id("org.jetbrains.kotlin.plugin.sam.with.receiver") version "{{ site.data.releases.latest.version }}"
id "org.jetbrains.kotlin.plugin.sam.with.receiver" version "{{ site.data.releases.latest.version }}"
}
```

</div>
</div>


然后指定需要特别处理的 SAM-with-receiver 注解:

```groovy
Expand Down
4 changes: 2 additions & 2 deletions pages/docs/reference_zh/whatsnew-eap.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
type: doc
layout: reference
category:
title: "Kotlin 2.0.0-Beta4 版中的新功能"
title: "Kotlin 2.0.0-Beta5 版中的新功能"
---

# Kotlin 2.0.0-Beta4 版中的新功能
# Kotlin 2.0.0-Beta5 版中的新功能

最终更新: {{ site.data.releases.latestDocDate }}

Expand Down

0 comments on commit 75d91d8

Please sign in to comment.