I read this code that is about quicksort
with monkey-patching for the Array
class.
class Array
def quicksort
return [] if empty?
pivot = delete_at(rand(size))
left, right = partition(&pivot.method(:>))
return *left.quicksort, pivot, *right.quicksort
end
end
I don't know what the star (*
) sign seen at the start of *left.quicksort
is. Can't we just use left.quicksort
?