我想使用分區enumerable method將數組分成兩個不同的數組。左邊的數組工作正常。爲什麼分區方法在數組的末尾添加nil?
def quicksort(array)
pivot = array.delete_at(6)
left, right = array.partition { |x| x < pivot }
puts "right's size"
puts right.size
puts 'right'
puts right
end
r = [14, 6, 41, 0, 5, 7294, 4, 25, 12, 24, 5, 2, 62, 67, 32, 78, 63, 3]
p quicksort(r)
這裏是從IRB
right's size
14
right
14
6
41
5
7294
25
12
24
5
62
67
32
78
63
nil
是什麼原因造成的nil
展現出來的結果?