proomt

Search

Search posts, papers, and topics

All posts

Ray Wenderlich1 min readtutorialintro

Kodebits Day 76: Elvis Operator [FREE]

Summary

A short Kodebits tip introduces Kotlin’s Elvis operator for handling nullable values, showing how it supplies a default when the left side is null. It’s a quick reminder for Android developers working with null‑safety.

  • The Elvis operator (?:) returns the left expression when it’s non‑null, otherwise evaluates and returns the right expression.
  • It lets you provide default values or fallback expressions concisely in Kotlin null‑safe code.

Kotlin Android developers should know the Elvis operator to write clearer, safer null‑handling code.

3/10

Related reading

  1. Kodebits Day 95: Lazy Sequences [FREE]

    This short Kotlin challenge demonstrates lazy sequences. It shows how `asSequence()` combined with `map`, `filter`, and `take` processes elements one at a time, evaluating lazily only when a terminal operation is called.

    Ray Wenderlichkodeco.com1 min