无法调换大小不同的数组

时间:2018-09-30 16:17:17

标签: ruby

我有一个像这样的数组

[["ContactCreate", "PolicyCreate"], ["Page_1", "Page_3"], ["Page_2"]]

我想转置这个数组,但是如果我转置这个数组,这说

Uncaught exception: element size differs (1 should be 2)

现在我有这样大小的数组,无论如何,我可以用更大数组的大小填充nil,然后可以转置吗?喜欢

[["ContactCreate", "PolicyCreate"], ["Page_1", "Page_3"], ["Page_2",nil]]

如果

 [["ContactCreate", "PolicyCreate","contactCreate], ["Page_1", "Page_3"], ["Page_2"]]

然后必须是

 [["ContactCreate", "PolicyCreate","contactCreate], ["Page_1", "Page_3",nil], ["Page_2",nil,nil]]

0 个答案:

没有答案