3 ms·
Is there no way to access all arguments or rest arguments in Go? Why limit map and traverse tuple to 2?
by zelphirkalt 3y ago
Is there no way to access all arguments or rest arguments in Go? Why limit map and traverse tuple to 2?
- cleue 3y agoUnfortunately there is no way to use variadic arguments in a type safe way in go (yet) - except for the special case that all arguments are of the same type. This is why some of the functions that work with many arguments (such as `Pipe`, `Flow`, `Traverse` ...) carry their cardinality as a suffix. Their shapes are then auto-generated up to a max cardinality that seems to make sense in practice. So the traverse tuple function does not only exist for cardinality 2 but also for higher ones. But unfortunately you have to specify it explicitly.