What do you think about the following one liner: ...
# stdlib
k
What do you think about the following one liner:
Copy code
inline fun <T> T.assuming(condition: (T) -> Boolean) = if (condition()) this else null
Example usage:
Copy code
val lines : String? = file.assuming { it.exists() }?.readText()
👍 3