Kotlin is a class-based object-oriented language. So, while we can have global functions like our main() functions, most of our code will reside in Kotlin classes.

The simplest possible Kotlin class is just the class name prefixed by class. Everything else is optional.

To create an instance of the class, you call a constructor function. By default, a Kotlin class gets a zero-parameter constructor, and constructor function names are the name of the class. So, by default, you can put () behind the class name, and that will create an instance of the class.

Note, though, that by default a Kotlin class does not get a useful toString() implementation, so the output of this script will be just [object Object].

You can learn more about this in:
Run Edit