I feel there's a way to simplify this, no? ```val ...
# getting-started
m
I feel there's a way to simplify this, no?
Copy code
val squares = squares.dropWhile { it.area < id - it.area }.take(2)
val previous = squares.first()
val current = squares.last()
e
moltendorf: Assuming the squares lambda works as you expect, you could inline declaration and initialization of previous and current like
val(previous, current) = squares.dropWhile { it.area < id - it.area }.take(2)
Updated example, based on feedback from group.
m
I've been using this (feature) all the time, and yet somehow it didn't click for this specific piece of code even when I revisited it today until I came on here and noticed you responded. Sorry I disappeared after asking. Thanks so much!
👍 1