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:
There are 24 hard keywords in kotlin which cannot be used as identifiers in any situation.
Below is the list of hard 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.
There are 29 modifier keywords in kotlin.
These tokens act as keywords in modifier lists of declaration and can be used as identifiers in another context.
Below is a list of modifier keywords.
- 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.