What about on the caller’s side? If the method has a splat parameter, it should be possible to call it “splatting” any Enumerable as the argument.
The use case is #values_at. I find that method mostly useless. You can be collecting indices or keys in an array, but you can’t retrieve their values with collection.values_at(*indices) because only tuples are splattable.
Since the signatures are #values_at(*indices : Int) for Indexable and #values_at(*keys : K) for Hash, #values_at(indices : Enumerable) and #values_at(keys : Enumerable(K)) should work without conflict, no?
Yeah. If the Hash key type is K | Enumerable(K), the type restriction for values_at would be Enumerable(K | Enumerable(K)). So Enumerable(K) would match both overloads.
It’s a mess, because Hash#select/#reject work on keys, while the same methods in Enumerable work on values. I wouldn’t create an overload in Indexable#select that unexpectedly works on indexes.