i programming kotlin language to 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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With