Keywords in Kotlin

Jay Tillu
Blogs by Jay Tillu
Published in
2 min readNov 4, 2018
  • Keywords are predefined, reserved words that have special meaning in the language.
  • Generally, it is recommended not to use it as identifiers.
  • But in Kotlin, there are some keywords that can be used as identifiers in some situations.
  • There are basically four types of keywords in Kotlin:
  1. Hard keywords
  2. Soft keywords
  3. Modifier keyword
  4. Special identifiers

Hard Keywords

  • There are 24 hard keywords in Kotlin that cannot be used as identifiers in any situation.
  • Below is the list of hard keywords.

Soft Keywords

  • There are 17 soft keywords in Kotlin.
  • These tokens act as a keyword in a certain context, but you can use them as identifiers in another context.
  • Below is a list of soft keywords.

Modifier Keywords

  • There are 29 modifier keywords in Kotlin.
  • These tokens act as keywords in modifier lists of declarations and can be used as identifiers in another context.
  • Below is a list of modifier keywords.

Special Identifier

  • The following two special identifiers are defined by the compiler in a specific context and can be used as regular identifiers in another context.
  • Below is a list of those two identifiers.

Please, Guys, avoid them to use as identifiers. It's 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.

Follow me for more such content.

--

--

Jay Tillu
Blogs by Jay Tillu

I am Frontend Web Developer and Hobbyist Blogger. As a Web Developer, I hold expertise in HTML, CSS, JavaScript, and React.