igor.wojda
09/06/2021, 6:16 AMCollection
type? Fine / Not Fine? and Why?
val modifiers: Collection<Modifier> = emptyList()
Tomasz Krakowiak
09/06/2021, 6:29 AMcontains
calls on large collection, than it's better to convert it to some set implementation first, as some Collection implementation may be not efficient for that. But if you just want to write a function that would iterate over elements and do whatever, than it would be better to accept a `Collection`(or even Sequence
), to remove the need of conversion of an arbitrary type of collection the caller uses to one that you use.Stephan Schroeder
09/06/2021, 6:40 AMCollection
has a size
, which `Iterable`/`Sequence` doesn't. List
provides an order of elements on top of Collection
. Set
provides a uniqueness guarantee on top of Collection
. Collection
would often be good enough (it's nice to iterate and to have the size, if only for log messages or something). But List
is shorter to write, so I mostly use List
even though I very often don't need any specific order 😅