W3cubDocs

/Kotlin

ContractBuilder

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalContracts interface ContractBuilder

Provides a scope, where the functions of the contract DSL, such as returns, callsInPlace, etc., can be used to describe the contract of a function.

This type is used as a receiver type of the lambda function passed to the contract function.

See Also

contract

Functions

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

callsInPlace

Specifies that the function parameter lambda is invoked in place.

abstract fun <R> callsInPlace(
    lambda: Function<R>, 
    kind: InvocationKind = InvocationKind.UNKNOWN
): CallsInPlace
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

returns

Describes a situation when a function returns normally, without any exceptions thrown.

abstract fun returns(): Returns

Describes a situation when a function returns normally with the specified return value.

abstract fun returns(value: Any?): Returns
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

returnsNotNull

Describes a situation when a function returns normally with any value that is not null.

abstract fun returnsNotNull(): ReturnsNotNull

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.contracts/-contract-builder/index.html