Sidebar, let's discuss in :thread-please:: If I'm ...
# announcements
a
Sidebar, let's discuss in 🧵: If I'm initializing an empty list, is there a performance difference between
emptyList()
and
ArrayList()
?
They read the same to me, but idk if one is preferred.
j
the former. always.
p
emptyList()
makes more sense to me
a
What's different?
d
emptyList
is a constant and not mutable
ArrayList
is a new, mutable list.
a
gotcha
1
p
emptyList()
returns
EmptyList
which is a singleton and should be faster than creating a new instance of array list.
a
Thanks all
a
Much appreciated. Lesson learnt.
p
checkout #C0B8MA7FA .. I am happy to assist