I came across a use case where I needed an `Exhaus...
# kotest-contributors
m
I came across a use case where I needed an
Exhaustive
of partial permutations/k-permutations of a list, so I modified the current
permutations(list: List<A>)
implementation a bit, adding
k: Int = list.size
as a parameter (where
k
cannot be larger than the list size and must be greater than zero). Effectively meaning that if you omit
k
, the function will behave just like before, but if you provide
k
you'd get permutations of size
k
. Would you be interested in a PR? If so, would you like me to modify the current method (what I've done locally) or perhaps add another method (like
partialPermutations()
or equivalent)?
e
IMO keep the existing method to keep binary compatibility but add
@Deprecated
, add another method with the additional param with a default value and we can replace the deprecated one completely in 6.0 or something 🙂 Imo the name can be kept as
permutations
, perhaps
k
could be just
permutationLength
,
length
or something else that's descriptive? Disclaimer: I work with Mikael (shoving Kotest down his throat all day) 😉
m
Allright, so I think we have three options here: 1. As described above, i.e. a new overloaded method with
length
added, but the original method deprecated. The downside with that is that any calls without an explicit parameter
length
, will "point" to the original method and thus get a deprecated-warning (and the only way to get rid of it is to explicitly add a
length
-value to every call). Does not feel nice IMO and possibly pretty confusing 2. Break binary compability (add
length
to the existing method) 3. Add a new method called
partialPermutations
or equivalent I'll adapt to your wishes but if the breaking part does not seem high risk/impact, I think option 2 is nicest API-wise.