Back to Type Challenges

README.Zh CN

questions/00018-easy-tuple-length/README.zh-CN.md

latest1.9 KB
Original Source
<!--info-header-start--><h1>获取元组长度 </h1><blockquote><p>by sinoon <a href="https://github.com/sinoon" target="_blank">@sinoon</a></p></blockquote><p><a href="https://tsch.js.org/18/play/zh-CN" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> <a href="./README.ja.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

创建一个Length泛型,这个泛型接受一个只读的元组,返回这个元组的长度。

例如:

ts
type tesla = ['tesla', 'model 3', 'model X', 'model Y']
type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT']

type teslaLength = Length<tesla> // expected 4
type spaceXLength = Length<spaceX> // expected 5
<!--info-footer-start-->

<a href="../../README.zh-CN.md" target="_blank"></a> <a href="https://tsch.js.org/18/answer/zh-CN" target="_blank"></a> <a href="https://tsch.js.org/18/solutions" target="_blank"></a> <!--info-footer-end-->