# Safe-Call Operator

The Kotlin safe call operator (?) accesses methods and properties of nullable variables while supporting null safety.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Practical Kotlin Deep Dive: Master Kotlin Internals and Ace Your Next Technical Interview

DevFeed: [Practical Kotlin Deep Dive: Master Kotlin Internals and Ace Your Next Technical Interview](<https://devfeed.tech/articles/practical-kotlin-deep-dive-master-kotlin-internals-and-ace-your-next-technical-interview-25926.md>)

Original publisher: [Read original article](<https://skydoves.medium.com/practical-kotlin-deep-dive-master-kotlin-internals-and-ace-your-next-technical-interview-33ff30f91493?source=rss-9bb203a4ab2e------2>)

Author: Jaewoong Eum

Published: 2026-02-18T03:55:53Z

Content type: article

Language: en

Sources: [Jaewoong Eum](<https://devfeed.tech/sources/stories-by-jaewoong-eum-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Learning](<https://devfeed.tech/topics/learning.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [runBlocking](<https://devfeed.tech/topics/runblocking.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [scope function](<https://devfeed.tech/topics/scope-function.md>), [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [book](<https://devfeed.tech/tags/book.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [course](<https://devfeed.tech/tags/course.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [deep-dive](<https://devfeed.tech/tags/deep-dive.md>), [insights](<https://devfeed.tech/tags/insights.md>), [interactive](<https://devfeed.tech/tags/interactive.md>), [internals](<https://devfeed.tech/tags/internals.md>), [interview](<https://devfeed.tech/tags/interview.md>), [keep](<https://devfeed.tech/tags/keep.md>), [knowledge](<https://devfeed.tech/tags/knowledge.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [language](<https://devfeed.tech/tags/language.md>), [lazy](<https://devfeed.tech/tags/lazy.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>), [technical-interview](<https://devfeed.tech/tags/technical-interview.md>)

### AI overview

Practical Kotlin Deep Dive teaches Kotlin internals through bytecode, compiler references, and KEEP proposals across 70 topics in six chapters. The excerpt highlights practical mechanisms: lambda objects explain the role of `inline`; coroutine cancellation exceptions can be swallowed by broad catches; and `kotlinx-serialization` generates serializers at compile time rather than relying on reflection. It also contrasts KAPT, which generates Java stubs for annotation processors, with KSP, which reads Kotlin symbols directly and is described as at least twice as fast in many projects. The companion course adds runnable playgrounds and 158 quizzes; the book and course share the same topic coverage, while the course includes practice and a completion certificate. These points describe the material presented in the supplied excerpt.

### Source excerpt

Most Kotlin developers can write a data class, launch a coroutine, or use lazy without thinking twice. These features work, the code compiles, and the app runs. But there is a gap between knowing how to use Kotlin and understanding what the compiler actually does with your code. That gap is where performance intuition, debugging skill, and technical interview confidence come from. Practical Kotlin Deep Dive is a book designed to close that gap, covering 70 Kotlin topics across 492 pages with bytecode decompilations, compiler source code references, and KEEP proposal analysis that reveal the machinery behind every feature you use daily. In this article, you'll explore what the book and its companion course cover, walking through each of the six chapters with examples of the insights you'll find inside. You'll see how the book approaches topics differently from typical Kotlin resources, what the "Pro Tips for Mastery" sections reveal about internal mechanisms, and how the interactive course format turns that knowledge into verified understanding through Code Playgrounds and 158 quiz questions. Beyond the syntax: Why internals matter Knowing that lazy caches a value on first access is useful. Knowing that the default lazy implementation uses double checked locking with a synchronized block, and that you can switch to a lock free compareAndSet strategy by passing LazyThreadSafetyMode.PUBLICATION, is the difference between using a feature and making informed decisions about it. The same applies across the language. Understanding that every lambda passed to a higher order function creates a Function object on the heap explains why inline exists. Seeing a data class decompiled into seven generated methods explains what the compiler is doing on your behalf. This is the approach Practical Kotlin Deep Dive takes throughout. Rather than describing what Kotlin features do, it examines how they work internally, what bytecode they produce, what design trade-offs the language desi

## KotlinConf 2025 Announcements

DevFeed: [KotlinConf 2025 Announcements](<https://devfeed.tech/articles/kotlinconf-2025-announcements-39349.md>)

Original publisher: [Read original article](<https://kt.academy/article/kotlinconf2025-announcements>)

Published: 2025-06-03T00:00:00Z

Content type: article

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [destructuring](<https://devfeed.tech/topics/destructuring.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [union types](<https://devfeed.tech/topics/union-types.md>), [syntax](<https://devfeed.tech/topics/syntax.md>), [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>)

Tags: [announcements](<https://devfeed.tech/tags/announcements.md>), [destructuring](<https://devfeed.tech/tags/destructuring.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlinconf](<https://devfeed.tech/tags/kotlinconf.md>), [new-features](<https://devfeed.tech/tags/new-features.md>), [safe-call-operator](<https://devfeed.tech/tags/safe-call-operator.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [union-types](<https://devfeed.tech/tags/union-types.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

The article summarizes announcements from KotlinConf 2025, including K2 becoming stable, upcoming name-based destructuring, and rich errors with language-level support for result-or-error types and related operators.

### Source excerpt

The greatest announcements from KotlinConf 2025.

## An opinionated guide on how to make your Kotlin code fun to read and joy to work with

DevFeed: [An opinionated guide on how to make your Kotlin code fun to read and joy to work with](<https://devfeed.tech/articles/an-opinionated-guide-on-how-to-make-your-kotlin-code-fun-to-read-and-joy-to-work-with-25931.md>)

Original publisher: [Read original article](<https://proandroiddev.com/an-opinionated-guide-on-how-to-make-your-kotlin-code-fun-to-read-and-joy-to-work-with-caa3a4036f9e?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-15T06:16:05Z

Content type: tutorial

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Code quality](<https://devfeed.tech/topics/code-quality.md>), [scope function](<https://devfeed.tech/topics/scope-function.md>), [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>), [conditionals](<https://devfeed.tech/topics/conditionals.md>), [if statement](<https://devfeed.tech/topics/if-statement.md>), [code beautification](<https://devfeed.tech/topics/code-beautification.md>), [pretty printing](<https://devfeed.tech/topics/pretty-printing.md>), [smart cast](<https://devfeed.tech/topics/smart-cast.md>), [constructor](<https://devfeed.tech/topics/constructor.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [code-style](<https://devfeed.tech/tags/code-style.md>), [guide](<https://devfeed.tech/tags/guide.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [style](<https://devfeed.tech/tags/style.md>)

### AI overview

The guide favors Kotlin code whose intent and types stay easy to read as code evolves. Put constructor properties on separate lines when there are multiple arguments, use named lambda parameters in multi-line or chained expressions, and name multiple callback lambdas. Reserve `let` for simple assignments or returns; avoid using it as general control flow or replacing `if`/`else` with `x?.let {} ?: run {}`. Prefer early returns with the Elvis operator when there is no alternate branch, explicit return types on public non-override functions, `val` where mutation is unnecessary, and non-null parameters when null is not meaningful. Use named data classes rather than positional decomposition or tuple return types when fields carry distinct meanings. The author also recommends read-only `List` types instead of exposing mutable list types, built-in collection operations instead of equivalent loops, and choosing function types, `fun interface`, or regular interfaces according to whether callbacks need a name or multiple methods. These are presented as style recommendations, with some preferences explicitly personal or situational.

### Source excerpt

I've been meaning to write this article in a while. Hopefully, the following tips and style recommendations (in no particular order) will help you write better Kotlin! Let's get on with it, shall we? For 2 or more constructor arguments, prefer not to keep the properties on the same line as the class name in the constructor definitionclass MyClass( val a: A, val b: B, ): MyParentClass(a, b), MyInterface { // ... } This format is preferable, because when adding the 3rd argument, important bits (such as a possible base class or interface) can appear too far on the right side of the screen. Listing them one after the other (including the trailing comma since 1.4.21+) allows for better readability and extensibility (reducing the chance of causing merge conflicts with future code changes, for example). Prefer to use the scoping function 'let' only in assignments or return statements, but NOT as general control flow, or a "quick rename to 'it'" Oftentimes, Kotlin code tends to do something like this: fun myMethod(nullableA: A?) { nullableA?.let { // no it.x() // no it.y() // no it.z() // no } } (Note: in a method like this, A? could be replaced with A to take advantage of typed nullability, this is just an example.) To allow better maintainability and readability, we should instead prefer to only use ?.let { in simple assignments, or return statements, but not as general control flow. For example, the following chain is easy to understand: val protoClass = savedInstanceState?.getByteArray("protoValue") ?.let { ProtoClass.parseFrom(it) } However, in this case, ?.let { is part of an assignment. Also, while ?.let { can be chained with a ?: to provide a default value (especially in combination with takeIf) it shouldn't be used to execute side-effects (also is more suitable for that). In fact, it needs to be said: x?.let {} ?: run {} is NOT a general purpose replacement for if-else statements and null-checks, and should never be used in this particular format for that purpose!

## The hidden pitfalls of the Elvis operator

DevFeed: [The hidden pitfalls of the Elvis operator](<https://devfeed.tech/articles/the-hidden-pitfalls-of-the-elvis-operator-25887.md>)

Original publisher: [Read original article](<https://medium.com/google-developer-experts/the-hidden-pitfalls-of-the-elvis-operator-da536ba68161?source=rss-1331e67af4e1------2>)

Author: Danny Preussler

Published: 2020-07-28T08:05:18Z

Content type: article

Language: en

Sources: [Danny Preussler](<https://devfeed.tech/sources/stories-by-danny-preussler-on-medium.md>)

Topics: [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>), [if expression](<https://devfeed.tech/topics/if-expression.md>)

Tags: [elvis-operator](<https://devfeed.tech/tags/elvis-operator.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [pitfalls](<https://devfeed.tech/tags/pitfalls.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

Kotlin's Elvis operator evaluates its entire left-hand expression before deciding whether to run the right-hand side, so it is not always equivalent to an if/else. In a chain such as `data?.let { updateData(data) } ?: run { showLoadingSpinner() }`, the fallback depends on the value returned by `updateData` as well as whether `data` is null. If that call returns null, both the update and loading spinner can run. The excerpt recommends making the intended either-or behavior explicit; it also notes that Kotlin expressions, including `let` and `run` blocks, return values.

### Source excerpt

Hidden pitfalls when using Elvis operator I guess many of us love Elvis, both the artist and the operator in Kotlin. But it can lead to some hidden pitfalls if you are not aware of how it works. https://unsplash.com/photos/1LCzr14Ah5U I only realized recently when Vladimir Zdravkovic put some code on twitter and ask us to guess what it's printing: https://twitter.com/vlazdra/status/1287366531987406848?s=20 I assumed a hidden puzzle but I could not see the issue. I could not see any reason why this would print anything but it does! After thinking about the issue (Vladimir wrote an article about it) I found more and more cases where this could go wrong. But let me show you some code: Kotlin's null safety I think most of us love the way we can easily write null safe code with Kotlin like this: presenter?.onDestroy() or data?.let{ updateData(data) } And it is super easy to add an alternative case: data?.let{ updateData(data) } ?: run { showLoadingSpinner() }Let me ask you something Do you think the following code is basically the same as the above? if (data != null) { updateData(data) } else { showLoadingSpinner() } I'm sure most of us do think they are equivalent. But what if I told you, it's not? The if/else is totally binary, it's either-or. But with the Elvis operator, it might be both! To understand why we have to look closer to how it works. Other than the else that belongs explicit to an if , the Elvis operator is not tied to a single ?. Remember, we can chain them: someVariable?.someField?.doSomething() if we now add the Elvis operator here, it will get executed depending on the expression to its left side: someVariable?.someField?.doSomething() ?: run { doSomethingElse() } so if any expression in there is null, the Elvis block will get called. It will finish evaluating everything on the left before checking if the operator is needed. This includes the last expression. So this is depending on whatever doSomething() returns! If it is null, then the right side wil

## The Ruby Safe Navigation Operator

DevFeed: [The Ruby Safe Navigation Operator](<https://devfeed.tech/articles/the-ruby-safe-navigation-operator-28303.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/ruby/2019/11/16/the-ruby-safe-navigation-operator.html>)

Author: Fuzzygroup

Published: 2019-11-16T00:00:00Z

Content type: article

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>)

Tags: [activerecord](<https://devfeed.tech/tags/activerecord.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [operator](<https://devfeed.tech/tags/operator.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

### AI overview

RuboCop flags an explicit nil check before a method call and recommends Ruby's safe navigation operator. In the example, a Streak record is fetched and activated only if found (`s.activate if s`); rewriting this as `s&.activate` calls `activate` when `s` is non-nil and returns nil otherwise. The author finds the original conditional clearer, while noting that safe navigation shortens a common Ruby pattern. The post also describes running RuboCop on individual files after leaving its Lefthook configuration commented out to avoid a large batch of reported issues.

### Source excerpt

So I recently moved to running my Ruby code thru RuboCop prior to each submission courtesy of the magic that is Lefthook. I don't always fix everything that RuboCop detects but I tend to read thru the reports. I'm using the "Boy Scout" approach to campsites, i.e. leave your campsite (code base) better than you found it, to at least make some of the changes each time. Note: To avoid the massive amount of errors that Rubocop detects via lefthook, I actually have the rubocop options in lefthook.yml commented out: # rubocop: # tags: backend style # glob: "*.rb" # exclude: "application.rb|routes.rb" # run: bundle exec rubocop --force-exclusion {all_files} and then I run the files individually using: rubocop -c .rubocop.yaml app/controllers/streaks_controller Here was an interesting error that it just detected: app/controllers/streaks_controller.rb:43:7: C: Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method. s.activate if s ^^^^^^^^^^^^^^^ So what we have here is an ActiveRecord operation and then an if clause: s = Streak.where(user_id: current_user.id, id: streak_id).first s.activate if s The Safe Navigation operator, &, is designed to be a more concise approach to something like the try operator in that it avoids errors when a method is called on nil: As its name reflects, the safe navigation operator allows us to safely call a method on a object that can be nil, in the same way as try! does in ActiveSupport. In that regard, if the object is not nil, it sends the method to the object, returning nil otherwise. Competa Using the safe navigation operator, the above code snippet can be written as: s = Streak.where(user_id: current_user.id, id: streak_id).first s&.activate This is one of those cases where I like the clarity of my original approach but the safe navigation operator does shorten up a coding paradigm that is almost everywhere in Ruby code. References Reasons to Not Use Safe Navigation More on the Safe