SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

KOTLIN / NOTES</>↗
Kotlin28 Jun 2026

How do I use run, apply, also, and with for cleaner Kotlin code?

In Kotlin, run, apply, also, and with are scope functions. They help make code cleaner by giving you a temporary scope around an object. The main differences are: Function Object reference Returns Best used for apply this The original object Configuring an object also it The original object Side effects, logging, validation run this Lambda […]

Wayan · 4 min read
KOTLIN / NOTES</>↗
Kotlin26 Jun 2026

How do I throw an exception when a value is null using ?: throw in Kotlin?

Use Kotlin’s Elvis operator ?: with throw on the right-hand side: val value: String? = getNullableValue() val nonNullValue: String = value ?: throw IllegalArgumentException("value must not be null") Because throw is an expression in Kotlin, it can be used after ?:. Example fun printLength(text: String?) { val nonNullText = text ?: throw IllegalArgumentException("text must not […]

Wayan · 1 min read
KOTLIN / NOTES</>↗
Kotlin26 Jun 2026

How do I use the Elvis operator to provide default values in Kotlin?

In Kotlin, the Elvis operator ?: provides a fallback value when the expression on its left is null. val result = nullableValue ?: defaultValue If nullableValue is not null, result gets that value. If nullableValue is null, result gets defaultValue. Example: val name: String? = null val displayName = name ?: "Guest" println(displayName) // Guest […]

Wayan · 1 min read
KOTLIN / NOTES</>↗
Kotlin26 Jun 2026

How do I use the safe call operator `?.` in Kotlin?

In Kotlin, the safe call operator ?. lets you access a property or call a function only if the value is not null. If the value is null, the expression simply returns null instead of throwing a NullPointerException. val name: String? = null val length = name?.length println(length) // null Here, name is nullable because […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.