# How Kotlin Single-Expression Functions Can Cause Subtle Business Logic Bugs

DevFeed: [How Kotlin Single-Expression Functions Can Cause Subtle Business Logic Bugs](<https://devfeed.tech/articles/don-t-let-kotlin-s-single-expression-function-ruin-your-business-25713.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/dont-let-kotlins-single-expression-function-ruin-your-business/>)

Author: Shreyas Patil

Published: 2021-05-24T14:42:29Z

Content type: tutorial

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [IntelliJ IDEA](<https://devfeed.tech/topics/intellij-idea.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [developer](<https://devfeed.tech/tags/developer.md>), [developers](<https://devfeed.tech/tags/developers.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-beginner](<https://devfeed.tech/tags/kotlin-beginner.md>), [programming-tips](<https://devfeed.tech/tags/programming-tips.md>), [studio](<https://devfeed.tech/tags/studio.md>)

## AI overview

This tutorial explains how Kotlin's automatic return-type inference in single-expression functions can cause a function to return a lambda unexpectedly. It recommends specifying return types explicitly to catch related mistakes at compile time and improve code readability.

## Source excerpt

Understand why relying on Kotlin's automatic type inference in single-expression functions can lead to subtle bugs and business logic failures.