Which style is more idomatic, or looks/used by vas...
# announcements
a
Which style is more idomatic, or looks/used by vast majority of community? 1.
list.map { it.toInt() }
2.
list.map(String::toInt)
3.
list.map { str: String -> str.toInt() }
2️⃣ 4
🥇 15
m
although a minimal difference,
String::toInt
is slightly faster iirc. Another benefit of 2 (and 3) is that the function is typed. And if someone (accidently) changes its type from String to something else, you'll get a compile error, forcing you to take another look at the function to see what would best fit now.
a
@Michael de Kaste they compile to same bytecode, I've checked by decompiling into java.