Kotlin 語言中的“關鍵字” Keywords in Kotlin修飾符關鍵字

image.png

關鍵字是預定義的保留字, 在語言中具有特殊含義。 不能將其用作標識符。

但在 kotlin, 有一些關鍵字在某些情況下可以用作標識符。 在 kotlin 中基本上有四種類型的關鍵字:

1.硬關鍵字 2.軟關鍵字 3.修飾符關鍵字 4.特殊標識符

Keywords are predefined, reserved words that have special meaning in the language. Generally it is recommended to do not use it as identifiers. But in kotlin there are some keywords which can be used as identifiers in some situations. There are basically four types of keywords in kotlin: Hard keywords Soft keywords Modifier keyword Special identifiers

硬關鍵字

在 kotlin 有24個硬關鍵字, 在任何情況下都不能用作標識符。 下面是硬關鍵字的列表。

Hard Keywords There are 24 hard keywords in kotlin which cannot be used as identifiers in any situation. Below is the list of hard keywords.

image.png

軟關鍵字

在Kotlin 中有17個軟關鍵字。 這些標記在特定上下文中充當關鍵字, 但您可以在其他上下文中將其用作標識符。 下面是軟關鍵字的列表。

Soft Keywords

There are 17 soft keywords in kotlin. These tokens acts as a keyword in certain context, but you can use them as identifiers in other context. Below is a list of soft keywords.

image.png

修飾符關鍵字

在 Kotlin 中有29個修飾語關鍵字。 這些標記充當聲明修飾者列表中的關鍵字, 並可在其他上下文中用作標識符。 下面是修飾符關鍵字的列表。

Modifier Keywords

There are 29 modifier keywords in kotlin. These tokens acts as keywords in modifier lists of declaration and can be used as identifiers in other context. Below is a list of modifier keywords.

image.png

特殊標識符

以下兩個特殊標識符由編譯器在特定上下文中定義, 可用作其他上下文中的常規標識符。 下面是這兩個標識符的列表。

Special Identifier

Following two special identifiers are defined by the compiler in specific context and can be used as regular identifiers in other context. Below are list of that two identifier.

請避免將它們用作標識符。避免使用關鍵字作爲標識符。

所以, 夥計們, 這是關鍵字。請隨時詢問任何疑問。

堅持編碼, 保持愛。

Please Guys avoid them to use as identifiers. Its my best suggestion to you in just one word. Avoid Keywords as Identifiers.

So guys, that’s it for keywords. Feel free to ask for any queries.

Till then Keep Coding, Keep Loving.

原文鏈接:https://medium.com/jay-tillu/keywords-in-kotlin-a429247a1802

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章