Kotlin takeIf와 takeUnless함수
takeIf 함수 람다식이 true이면 결과값을 반환. public inline fun T.takeIf(predicate: (T) -> Boolean): T? = if (predicate(this)) this else nulltakeUnless 함수 람다식이 false이면 결과값을 반환. public inline fun T.takeIf(predicate: (T) -> Boolean): T? = if (!predicate(this)) this else null예제 val user = "KaSha" val str = "Sha" var index = 0 index = user.indexOf(str).takeIf { it >= 0 } ?: -1 index = user.indexOf(str).takeUnless ..