# CloseableKt

Added in 1.1.0

*** ** * ** ***


```
public final class CloseableKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<T extends https://developer.android.com/reference/androidx/datastore/core/Closeable, R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/datastore/core/CloseableKt#(androidx.datastore.core.Closeable).use(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull T receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull T, @https://developer.android.com/reference/androidx/annotation/NonNull R> block )` Ensures a Closeable object has its close() method called at the end of the supplied block. |

## Public methods

### use

Artifact: [androidx.datastore:datastore-core](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/core/Closeable.kt+function:use) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.1.0)

```
public static final @NonNull R <T extends Closeable, R extends Object> use(
    @NonNull T receiver,
    @NonNull Function1<@NonNull T, @NonNull R> block
)
```

Ensures a Closeable object has its close() method called at the end of the supplied block.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html` | any exceptions thrown in the block will propagate through this method. |