https://kotlinlang.org logo
Title
c

Czar

02/04/2019, 8:49 AM
Static imports can be bad for code readability. For example, I've had a misfortune to deal with a code base with these collection "literals" all over it:
of(a, b, c)
, where
of
was a static import of
ImmutableList.of
,
ImmutableSet.of
etc. You always had to look at the imports to understand the code. Arguably that's a naming/misunderstood intention problem though, Google Collections' team obviously intended
*.of
not to be statically imported.
n

natpryce

02/04/2019, 9:30 AM
So the Kotlin convention to use top level functions avoids even that pitfall.
E.g. listOf(1, 2, 3) vs setOf(1, 2, 3)
c

Czar

02/04/2019, 11:24 AM
Yup 🙂 Although I have no doubt, that people calling using
of(1,2,3)
in Java will happily commit the same atrocity in Kotlin
n

natpryce

02/04/2019, 12:14 PM
😄