This is a quick guide to Kotlin programming language. The previous part of this guide is here
#Object Oriented
fun main(args : Array<String>) {
class local (val x : Int)
val y = local(10)
println("${y.x}")
This is a quick guide to Kotlin programming language. The previous part of this guide is here
#Object Oriented
fun main(args : Array<String>) {
class local (val x : Int)
val y = local(10)
println("${y.x}")
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.
package com.example.android.cookies; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
public class MainActivity extends AppCompatActivity { | |
@Override |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
import java.io.Serializable; | |
// must implement Serializable in order to be sent | |
public class Message implements Serializable{ | |
private final String text; | |
public Message(String text) { | |
this.text = text; | |
} |
FKScaffold( | |
modifier = Modifier.fillMaxSize(), | |
topBar = { | |
FKLargeTopAppBar(title = name) | |
}, | |
) { padding, triggerAccessoryView -> | |
ItemForm( | |
modifier = Modifier.padding(top = padding.calculateTopPadding()), | |
state = state, | |
dispatch = viewModel::dispatchEvent |
package dev.abd3lraouf.learn.myapplication | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.activity.enableEdgeToEdge | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.ExperimentalLayoutApi | |
import androidx.compose.foundation.layout.WindowInsets | |
import androidx.compose.foundation.layout.fillMaxSize |