so I had this case where I had a collection<T> where T had 10+ attributes; but each T is uniquely identified by T.a, T.b, T.c
and a stupid bug I caused was due to me doing
val map = collection.associateBy { Triple(it.a, it.b, it.c) }
and then doing
map.keys.filter { it.first == x }
instead of `map.keys.filter { it.second == x }`;
simplest way to avoid that seemed to be; in the context of the function;
val map = collection.associateBy { K(it.a, it.b, it.c) }
and then
map.keys.filter { it.b == x }
and given
K
was only needed in the context of said function, didn't need to be pulled out or exposed (even with
internal
)
what I'm not sure of; if this is a "recommended" pattern