Color theme
0 day streak0 XPP1
KotlinLearn mode
MISSION 1 OF 1

Sign a guest postcard

0 XP earned
Kotlin track: IntermediateMission: IntermediateNullable typesSafe callsElvis operator
Before you start this intermediate track

Functions and collections. Read lambdas, nullable values, and conditional expressions.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A postcard can have an optional nickname. The question mark in String? permits null. A safe call with ?. runs uppercase only when the nickname exists. The Elvis operator ?: supplies FRIEND if that result is null. A present name is preserved and formatted; a missing name gets a readable greeting.

Main.kt
fun main() {    val nickname: String? = null    val greeting = nickname?.uppercase() ?: "FRIEND"    println("Hello, $greeting!")}

Each mission is a complete independent Kotlin/JVM program with its own main function. Run it with Kotlin 1.9 or later in a Kotlin playground or a configured Kotlin/JVM project. No Android APIs are required.

Track the values line by line. Predict the result before running this example in your own editor.