arr = Array.dimension(3)
arr[0][0][0] = 0
arr[0, 1, 2] = 1
arr[2, 2, 2, 2] = [2, 2] # 前两个2为索引,第3个2为start,第4个2为length
arr[2, 3, 1..3] = *3..5
arr #=> [[[0], [nil, nil, 1]], [], [[], [], [nil, nil, 2, 2], [nil, 3, 4, 5]]]
arr.join #=> "0122345"
arr.compact.map {|n| n + 1 } #=> [[[1], [2]], [], [[], [], [3, 3], [4, 5, 6]]]
arr.each_index.to_a #=> [[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 1, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 3], [2, 3, 0], [2, 3, 1], [2, 3, 2], [2, 3, 3]]
arr = Array.dimension(3)
arr[0][0][0] = 0
arr[0, 1, 2] = 1
arr[2, 2, 2, 2] = [2, 2] # 前两个2为索引,第3个2为start,第4个2为length
arr[2, 3, 1..3] = *3..5
arr #=> [[[0], [nil, nil, 1]], [], [[], [], [nil, nil, 2, 2], [nil, 3, 4, 5]]]
arr.join #=> "0122345"
arr.compact.map {|n| n + 1 } #=> [[[1], [2]], [], [[], [], [3, 3], [4, 5, 6]]]
arr.each_index.to_a #=> [[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 1, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 3], [2, 3, 0], [2, 3, 1], [2, 3, 2], [2, 3, 3]]