william
10/25/2020, 2:30 PMList
type for return values or ImmutableList
? i don't want the downstream consumers to modify it (which either would provide). It kind of seems like an implementatino details that i am using ImmutableList
Nir
10/25/2020, 4:49 PMImmutableList
, IMHONir
10/25/2020, 4:49 PMList
, there is no way to know if that's a read-only view of a potentially-mutable class, or a read-only view of an immutable classNir
10/25/2020, 4:50 PMfoo
from a List
, it wouldn't be safe. So, if you have a function that returns List
, and you wanted to construct foo
from it, you'd need basically perform a defensive copy to get your ImmutableList
Nir
10/25/2020, 4:51 PMmap
which return List
but should really return ImmutableList
.william
10/25/2020, 5:50 PM