What should be considered when deciding whether to...
# codingconventions
m
What should be considered when deciding whether to declare destructuring functions (e.g.
component1()
) directly on a class vs. extension functions? AFAIR, when using destructuring extension functions, you need to add the imports manually.
m
I don’t fully understand, sorry: do you mean declaring
componentN()
functions manually, like the compiler does for data classes?
p
IMO positional destructuring is only very rarely a good idea. If you did decide to use it, I would definitely say to just make them member functions so you don’t have to import the extensions
m
@Paul Griffith There are some useful cases. I like using them from
Pair
MatchResult.destructured
for example. Likewise, there are occasions when I like to declare my own.