logoalt Hacker News

aabdelhafezlast Friday at 3:18 PM2 repliesview on HN

It's idiomatic in Kotlin as well!

https://kotlinlang.org/docs/scope-functions.html


Replies

zaphirplanelast Friday at 8:34 PM

So many options why oh why. let run with also apply

show 1 reply
simon_voidlast Friday at 6:05 PM

I agree, i started with (scope) blocks in Rust, but keep the habit in Kotlin win the run - scope-function. Since run takes no arguments, it feels like the closest equivalent to Rust scopes (compared to other Korlin scope functions, which also keep their local variables from polluting the rest of the function body).