Animesh Sahu
06/03/2020, 5:17 PMlist.map { it.toInt() }
2. list.map(String::toInt)
3. list.map { str: String -> str.toInt() }
Michael de Kaste
06/04/2020, 7:26 AMString::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.Animesh Sahu
06/04/2020, 7:26 AMMichael de Kaste
06/04/2020, 7:30 AM