Added lazy extensions
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package net.axay.kspigot.kotlinextensions
|
||||
|
||||
inline fun <T, R> Lazy<T>.ifInitialized(block: (T) -> R) = if (isInitialized()) block(value) else null
|
||||
|
||||
fun Lazy<AutoCloseable>.closeIfInitialized() = ifInitialized { value.close() }
|
Reference in New Issue
Block a user