3 ms·
It'd be nice if you could inline the Tuple description into the method signature. There's a bit of unnecessary overhead in having to externally declare and imp
by yarg 4y ago
It'd be nice if you could inline the Tuple description into the method signature.
There's a bit of unnecessary overhead in having to externally declare and import the return type.
public [K key, V value] getElement(int index);
This really comes down to the dynamic vs typed argument, and to me the answer is "minimise the boiler-plate, maximise the guarantees.".
- haimez 4y agoI think declaration vs use Sue distinction is much more helpful to reason about in this context, and named tuples are a classic example of “if you didn’t declare these tuples to be compatible at definition time, it’s probably a bug to let you pass them around as if they were”
- yarg 4y agoCodesmell sure - and a case for refactoring, but I wouldn't go as far as to say bug. But I wouldn't expect that to be the common use case - I'd generally expect that the caller would just be implicitly importing and using the type effectively declared in the method header.