# How to return 2+ values with 0 allocation in Kotlin

DevFeed: [How to return 2+ values with 0 allocation in Kotlin](<https://devfeed.tech/articles/how-to-return-2-values-with-0-allocation-in-kotlin-26303.md>)

Original publisher: [Read original article](<https://blog.louiscad.com/how-to-return-2-values-with-0-allocation-in-kotlin>)

Author: Louis CAD

Published: 2021-09-20T11:29:26Z

Content type: tutorial

Language: en

Sources: [Louis CAD doing software](<https://devfeed.tech/sources/louis-cad-doing-software.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Refactoring](<https://devfeed.tech/topics/refactoring.md>)

Tags: [compiler](<https://devfeed.tech/tags/compiler.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-languages](<https://devfeed.tech/tags/programming-languages.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>), [val](<https://devfeed.tech/tags/val.md>)

## AI overview

A Kotlin technique for returning multiple values from a function without extra allocation or a separately named class. The approach combines inline functions or lambdas, read-only properties, and contracts, while noting the potential code-size tradeoff of inlining.

## Source excerpt

The problem Most programming languages, including Kotlin, only allow returning one value, and there's a reason for that: We don't want to depend solely on the order of the parameters, because it can easily break through refactoring, or even before th...