我正在尝试创建一个字符串数组数组,如下所示:
let rules : type = [
["N"]
["N", "N"]
["N", "N", "N"]
]
但是我无法设置类型。我怎么能这样做?
答案 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"]
];