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