From: Simon Strandgaard Date: 2004-08-14T20:20:46+09:00 Subject: [RCR] Array#transpose way of dealing with nil's At the moment #transpose rejects nil values. It could be really nice if one tell #transpose that it whenever it meets a nil entry.. that a nil value also should be outputted. [[1, 2], [3, 4], nil, [5, 6]].transpose(true) #=> [[1, 3, nil, 5], [2, 4, nil, 6]] I often find myself needing this for unittesting.. like this def generic_test_bracket_matcher(str, inpos, expected_xs, expected_ys) res = inpos.map {|p| str.match_bracket(p) } ys, xs = res.transpose # BOOM: this doesn't like nil elements assert_equal(expected_xs, xs) assert_equal(expected_ys, ys) end -- Simon Strandgaard