←back to thread

218 points generichuman | 6 comments | | HN request time: 0.879s | source | bottom
1. 90s_dev ◴[] No.44001031[source]
Tuples: {number, string}

Arrays: {number}

How does it disambiguate it? Are single-element tuples just never used in practice? To be fair, maybe the only time I've had to use them in TypeScript is via Parameters<T>

replies(2): >>44004244 #>>44005545 #
2. johnisgood ◴[] No.44004244[source]
Now I am curious what {number, string, number} would be considered as.
replies(1): >>44005559 #
3. hisham_hm ◴[] No.44005545[source]
In our experience, single-element tuples are just never used in practice. There has been some discussion on how to add syntax for them, but I think it's more of a desire for orthogonality than for a practical need.
replies(1): >>44005795 #
4. hisham_hm ◴[] No.44005559[source]
it's a three element tuple.
replies(1): >>44005980 #
5. 90s_dev ◴[] No.44005795[source]
Yeah I can't imagine any scenario where it's not just a value or an array of values that happens to have only one value right now.
6. johnisgood ◴[] No.44005980{3}[source]
That was my guess, just as {n, n, n, n} would be a four element tuple, right?