多个字符串数组的数组

时间:2016-03-01 17:59:28

标签: typescript

我正在尝试创建一个字符串数组数组,如下所示:

let rules : type = [
 ["N"]
 ["N", "N"]
 ["N", "N", "N"]
]

但是我无法设置类型。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

这里有几种选择。最好的方法是作为真正的数组阵列:

-[NSView accessibilitySetOverrideValue:... forAttribute:NSAccessibilityTitleAttribute]

let rules : string[][] = [
 ["N"],
 ["N", "N"],
 ["N", "N", "N"]
];

您也可以使用单元素tuple types键入它,但这并不是元组类型的预期用法:

let rules : Array<Array<string>> = [
 ["N"],
 ["N", "N"],
 ["N", "N", "N"]
];

let rules : [string[]] = [
 ["N"],
 ["N", "N"],
 ["N", "N", "N"]
];

let rules : [string][] = [
 ["N"],
 ["N", "N"],
 ["N", "N", "N"]
];