Kotlin
Google's officially supported language for Android — concise, null-safe, and just as at home on the backend.
22 មេរៀន
Kotlin
ចាប់ផ្តើមវគ្គសិក្សាGetting Started
- What is Kotlin?What Kotlin is, why Google made it Android's preferred language, and where else it shows up today.
- Variables — val and varKotlin's two ways to declare a variable, and why you should reach for val by default.
- Basic Types and Type InferenceKotlin's core types and how the compiler figures out most of them without annotations.
Strings & Null Safety
- String TemplatesEmbedding variables and expressions directly inside strings instead of concatenating pieces by hand.
- Nullable TypesHow Kotlin's type system distinguishes values that can be null from values that never can, catching a huge class of bugs at compile time.
- Safe Calls and the Elvis OperatorThe ?. and ?: operators that let you work with nullable values concisely instead of writing a null check every time.
- The Not-Null Assertion (!!)Kotlin's escape hatch for bypassing null checks, and why reaching for it usually means reaching for the wrong tool.
Control Flow
- if as an ExpressionWhy Kotlin's if can produce a value directly, removing a whole category of temporary-variable boilerplate.
- The when ExpressionKotlin's replacement for switch statements — far more flexible, and just as safe as if when used as an expression.
- Loops and Rangesfor, while, and the range expressions (1..10, downTo, step) that make Kotlin's loops read like plain English.
Functions
- Functions, Default and Named ArgumentsDeclaring functions in Kotlin, and the default/named argument features that eliminate most overload boilerplate.
- Single-Expression FunctionsThe = shorthand for functions whose body is one expression, and how it works with type inference.
- Lambdas and Higher-Order FunctionsPassing behavior as a value — anonymous functions and the functions that accept them as parameters.
Collections
Classes & Object-Oriented Kotlin
- Classes and ObjectsDeclaring classes, constructors, and properties — and how Kotlin collapses fields, getters, and setters into one concept.
- Data ClassesThe data class declaration that generates equals, hashCode, toString, and copy for classes that primarily hold values.
- Inheritance and InterfacesWhy Kotlin classes are closed to inheritance by default, and how open, override, and interfaces work together.
- Extension FunctionsAdding new functions to existing classes — including ones you don't own the source of — without inheritance.
- Sealed ClassesRestricting a type to a known, closed set of subclasses so the compiler can verify every case is handled.
Concurrency & Beyond