book icon indicating copy to clipboard operation
book copied to clipboard

Wouldn't the following sample code be better? (タプル型の例としては異なる型のペアのほうが例として好ましくないですか?)

Open RHxyz009abc opened this issue 11 months ago • 1 comments

Features of TypeScript. Advanced type expression. 2. Tuple type: A type that allows you to specify a different type for each element of the array. type Point2D = [number, number];

https://github.com/yytypescript/book/blob/93c3a5c342988a97274a1eea4d09ab8a6cdaf201/docs/overview/features.md?plain=1#L56

Wouldn't the following sample code be better? type Point2D = [number, string];

RHxyz009abc avatar Mar 14 '24 01:03 RHxyz009abc

Certainly! Having different types in a tuple indeed showcases the unique capability of tuple types more effectively. However, including a string in Point2D might seem unnatural, suggesting that a significant change to the example could be beneficial.

ja: たしかに!異なる型同士のほうが、タプル型らしさが出ますね。Point2Dがstringを持つのは不自然なので、例を大きく変える必要はありそうですね。

suin avatar Mar 22 '24 10:03 suin