Is there something similar to `reduce` that works ...
# stdlib
s
Is there something similar to
reduce
that works for empty collections by returning
null
? I can see that there are specializations of it (
.minBy
,
.minWith
, ..) but a general version escapes me.
e
No. But you can emulate:
Copy code
c.takeIf { it.isNotEmpty() }?.reduce { ... }
m
fold
👆 1