The program shape in Kotlin
The smallest Kotlin program: no class, no package line, just main.
// A Kotlin file needs no ceremony: main is the whole program.
fun main() {
val hut = "Larkspur Hut"
println("Lights on at $hut")
println("Beds free: ${18 - 11}")
}
How it works
- A top-level
fun main()is the whole entry point. valbinds the hut's name once;printlnwrites a line.$hutand${18 - 11}splice values and expressions into strings.
Keywords and builtins used here
funmainval
The run, in numbers
- Lines
- 6
- Characters to type
- 164
- Tokens
- 34
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 27 seconds.
Step 1 of 3 in Values, step 1 of 27 in Language basics.