contentintech
Languages

Kotlin

Null safety, collection transformations and concise data models.

Values

val name = "Ada"Create a read-only binding
var count = 0Create a mutable binding
val nickname: String? = nullExplicitly permit null
nickname?.length ?: 0Safe call followed by an Elvis fallback

Functions and models

fun add(a: Int, b: Int) = a + bDefine a function with inferred return type
data class User(val id: Int, val name: String)Generate value-style model helpers
val newer = user.copy(name = "Lin")Copy a data class with one changed field
val (id, name) = userDestructure a data class

Collections

val names = listOf("Ada", "Lin")Create a read-only list interface
val mutable = mutableListOf<String>()Create a mutable list
names.filter { it.startsWith("A") }Select matching elements
names.map { it.uppercase() }Transform each element

Section navigation