如何在Ruby中解压缩一个数组,如Python中的这些示例:
>>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> zipped = zip(x, y) >>> zipped [(1, 4), (2, 5), (3, 6)] >>> x2, y2 = zip(*zipped) >>> x == list(x2) and y == list(y2)
ruby arrays
arrays ×1
ruby ×1