DEV Community

Discussion on: Advent of Code 2019 Solution Megathread - Day 4: Secure Container

Collapse
 
jbristow profile image
Jon Bristow

Unsolicited code review:

filter(x).isEmpty() is equivalent to none(x)

filter(x).isNotEmpty() is equivalent to any(x)

filterNot(x).isEmpty() is equivalent to all(x)

filterNot(x).isNotEmpty() is equivalent to any(!x)

c.any{it == x} is equivalent to x in c

I find future me tends to remember what I was doing faster when I use the any/none/all functions. (They also short-circuit, but the readability boost to my productivity helps more than the loop optimization)