disposeSafely

fun Disposable?.disposeSafely()

Allows to gracefully dispose a resource implementing Disposable interface. Will silently ignore nulls and exceptions (except for JVM internal Errors, which should not be caught anyway).


fun <Asset : Disposable> Iterable<Asset?>?.disposeSafely(): Unit?

Allows to dispose a collection of resources implementing Disposable interface. Will silently ignore stored nulls and exceptions thrown during disposing (except for JVM internal Errors, which should not be caught anyway). This method does not affect the Iterable structure in any way: no elements are removed from the collection.


fun <Asset : Disposable> Array<Asset>?.disposeSafely(): Unit?

Allows to dispose a collection of resources implementing Disposable interface. Will silently ignore stored nulls and exceptions thrown during disposing (except for JVM internal Errors, which should not be caught anyway). This method does not affect the Array structure in any way: no elements are removed from the array.