![JAR search and dependency download from the Maven repository](/logo.png)
io.justdevit.kotlin.boost.extension.Int.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boost-commons Show documentation
Show all versions of boost-commons Show documentation
Library to boost working with Kotlin/JVM projects.
The newest version!
package io.justdevit.kotlin.boost.extension
/**
* Determines whether the integer is even.
*
* @return `true` if the integer is even, `false` otherwise.
*/
fun Int.isEven(): Boolean = this % 2 == 0
/**
* Executes the specified [action] only if the current integer is even.
*
* @param action The action to be executed if the integer is even.
*/
inline fun Int.ifEven(action: (Int) -> Unit) {
if (isEven()) action(this)
}
/**
* Determines whether the integer is odd.
*
* @return `true` if the integer is odd, `false` otherwise.
*/
fun Int.isOdd(): Boolean = !isEven()
/**
* Executes the specified [action] only if the current integer is odd.
*
* @param action The action to be executed if the integer is odd.
*/
inline fun Int.ifOdd(action: (Int) -> Unit) {
if (isOdd()) action(this)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy