Antonio Acuña Prieto
fun delete(id: UUID) = list.removeIf { it -> it.id == id }
fun delete(id: UUID) = takeIf { list.removeIf { it -> it.id == id } } ?: throw NotFoundException(id)
Vampire
fun delete(id: UUID) = if (list.removeIf { it -> it.id == id }) Unit else throw NotFoundException(id)
Endre Deak
fun delete(id: UUID) { takeIf { list.removeIf { it -> it.id == id } } ?: throw NotFoundException(id) }
phldavies
fun delete(id: UUID) { if (!list.removeIf { it.id == id }) throw NotFoundException(id) }
takeIf
A modern programming language that makes developers happier.