Perhaps a silly question. What is the best way to add a randomize
method to array? I know that this code will properly randomize an
array:
a.sort_by{ rand }
but I wonder how I can know add this to the array class. I can't
assign self to the result of this method, so this will not work:
class Array
def randomize
self = self.sort_by{ rand }
end
end
What is the best way to do this?