is there any reason to prefer null over empty coll...
# announcements
t
is there any reason to prefer null over empty collection as return value in kotlin?
1
l
I think it is not specific for any language, it is related for business logic
typical solution is return empty collection for collections and null for value
d
There are situations where both
null
and "empty collection" can be useful values, e.g.
null
meaning "not initialized yet" and "empty collection" meaning "initialized, but empty".
💯 1
l
yes, null for collections as "not initialized" can be (and should be) for domain object properties, but for business logic results (data, returned from services, etc) should be empty collection
4