Kotlin - Baby Steps
I was at Kotlin SG Meetup tonight. It had a lot of content. I will post more about that later.
On my way back home (now), I started reading Kotlin website about various features (here).
I was curious about command line usage of Kotlin. How will I complile kotlin classes outside an IDE? How to run this? What about the runtime libraries? etc.
It turns out to be very straight forward. No surprises.
- Just write your code in a
- Run kotlin compiler
a. For Apps, use
b. For libraries, DON’T include runtime
- Run app with
Now, I was more curious. I wanted to see if I could do one better. Can I write a script and execute it directly by filename? Lets try. Created a file
list_folders.kts, as below.
And, run this.
Wow! that worked. Trick is in the first line
This causes shell the use
kotlinc interpreter for this script.