I discovering the programming language kotlin for some weeks, and I always start with new File/Class, and I've noticed lately to kotlin Script in the menu and I ask now what's different between the Script and the normal File in kotlin
In a Kotlin source *.kt
file, you can place top-level declarations, such as types and top-level functions and properties, but not code statements that are not nested into some declarations.
A Kotlin Script *.kts
file, on contrary, contains code statements on the top level without any nesting. These statements are an equivalent of a main
function. It is allowed to contain types, too, but with some limitations similar to those placed on nested type declarations.