Kotlin has a require function which can be used like so (copied from the reference documentation):
fun getIndices(c