Modifier Keywords

A modifier keyword also has a meaning in a specific context. In this case, the context is a declaration, and the keyword can be used elsewhere as an identifier.

For example, public is a modifier keyword, so you could have a variable named public if you wanted:

fun main() {
  val public = 1337
  
  println(public)
}

You can even have a function named public:

class Foo {
  fun public() {
    println("I am public, and I am public()")
  }
}

fun main() {
  Foo().public()
}

There may be select areas where you cannot use modifier keywords as identifiers, but on the whole, you can.

Other notable modifier keywords include:


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.