Hello everyone! I want to use maxOf with 2 strings...
# getting-started
a
Hello everyone! I want to use maxOf with 2 strings but compare by the String.length. Something like
maxOf("aaaa","zzz")
and return
"aaaa"
. How could I achieve this?
r
Use a comparator:
Copy code
maxOf("aaaa", "zzz", compareBy { it.length })
a
Awesome!!! Thanks @Ruckus
👍 1