3 ms·
There is no tuple type in go. When you see a func() (A, error) that is not a function returning a tuple. It is a function returning two values that cannot be co
by corethree 3y ago
There is no tuple type in go. When you see a func() (A, error) that is not a function returning a tuple. It is a function returning two values that cannot be composed. You can't A(B()) if B returns two values. It's pure comedy.
- deleted 3y ago[deleted]
- duskwuff 3y ago> You can't A(B()) if B returns two values. You can if A is a function which takes two arguments, e.g. package main import "log" func A(x, y int) { log.Printf("%d, %d", x, y) } func B() (int, int) { return 1, 2 } func main() { A(B()) } https://go.dev/play/p/Jp4B0L6NJj2 https://go.dev/play/p/Jp4B0L6NJj2
- erik_seaberg 3y agoWhat you can't do is a(b(), c()) unless b and c return single values. And there are no slices or channels of tuples, return values must be destructured right away.
- deleted 3y ago[deleted]