Kotlin Syntax Part I — why am I excluded?

Last updated 1 year ago by Joao Alves

kotlin

Hi everyone again, welcome to article number on 2 of the Kotlin Playground Series. There wasn’t that much code in the previous article but if you read it, you probably saw some new syntax that you’re not familiar with if coming from Java.

In this and following article I’ll cover some of Kotlin base syntax as I believe it’s important before we jump into other examples. But enough talk and let’s look at some Kotlin code. Classes

There are some differences in declaring classes in comparison with Java. Let’s look at some examples in the code below. An important aspect in Kotlin is that you can declare multiple classes without any relation in the same file. Probably not what you want to do but nice for this example.

Kotlin classes are declared using the keyword class and consist of the class name, the header and the body surround by curly braces. But there a lot of optional things when declaring Kotlin classes.

Read full Article