commonMain.com.github.mustafaozhan.scopemob.OptionalScope.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of submob-metadata Show documentation
Show all versions of submob-metadata Show documentation
Set of useful scope and Higher-order functions
The newest version!
/*
Copyright (c) 2020 Mustafa Ozhan. All rights reserved.
*/
package com.github.mustafaozhan.scopemob
inline fun ensure(
vararg elements: T?,
closureSafe: () -> R
): R? =
if (elements.all { it != null }) {
closureSafe()
} else {
null
}
inline fun T?.justInCase(block: () -> Unit) {
if (this == null) block()
}