Kotlin when Expression (Switch Alternative) with Examples
Kotlin when expression explained: match values, several values per branch, ranges with in, type checks with is, and using when to return a value.
Kotlin tutorials for beginners: functions, classes and objects, interfaces, collections and small programs you can run in Android Studio.
Kotlin when expression explained: match values, several values per branch, ranges with in, type checks with is, and using when to return a value.
Learn Kotlin if, if-else and else-if with examples. Use if as an expression to return a value (Kotlin’s ternary operator), and avoid common mistakes.
Kotlin logical operators (&&, ||, !), assignment operators (+=, -=, *=), increment and decrement (++, –) and the in operator, with examples and output.
Print output and read user input in Kotlin with print, println and readln. Read numbers safely, read several values on one line, and format output.
Kotlin strings with examples: string templates, length, substring, split, replace, trim, comparing strings, multiline raw strings and buildString.
Convert types in Kotlin: Int to Double, String to Int with toInt and toIntOrNull, numbers to String, Char to Int, and avoiding NumberFormatException.
Kotlin data types with examples: Int, Long, Byte, Short, Double, Float, Char, Boolean and String, their ranges, type inference and common mistakes.
Start writing Kotlin today: the online Kotlin Playground, IntelliJ IDEA, Android Studio or the kotlinc compiler. Pick the right setup for you.
Functions are an essential part of any programming language, and Kotlin is no exception. They allow us to encapsulate logic […]
Unit functions are functions in Kotlin that do not return any value. They are represented by the type ‘Unit’, which is equivalent to the ‘void’ type in Java. Unit functions are commonly used to perform some action, such as printing to the console, without returning a value.