Is there a particular function to retrieve then delete random array element?

ruby

Solution

How about this:

array.delete_at(rand(array.length))

Problem

I know I can do this in a couple of steps, but was wondering if there is a function which can achieve this. I want to array#sample, then remove the element which was retrieved.

Original source