# Effective Kotlin Item 5: Specify your expectations for arguments and state

DevFeed: [Effective Kotlin Item 5: Specify your expectations for arguments and state](<https://devfeed.tech/articles/effective-kotlin-item-5-specify-your-expectations-for-arguments-and-state-39278.md>)

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

Published: 2022-10-12T00: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>), [Requirements](<https://devfeed.tech/topics/requirements.md>), [Code](<https://devfeed.tech/topics/code.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Testing](<https://devfeed.tech/topics/testing.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [errors](<https://devfeed.tech/tags/errors.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [requirements](<https://devfeed.tech/tags/requirements.md>), [state](<https://devfeed.tech/tags/state.md>), [type-system](<https://devfeed.tech/tags/type-system.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

## AI overview

This article explains how to specify argument and state expectations in Kotlin using declarative checks such as argument checks, state checks, functions that signal unexpected states, and the Elvis operator. These checks make requirements visible, fail early with exceptions, help prevent partial state changes, and support smart casting.

## Source excerpt

How do we specify requirements and expectations in Kotlin.