Ruby Language Converting a Queue into an Array


Example

q = Queue.new
q << 1
q << 2

a = Array.new
a << q.pop until q.empty?

Or a one liner:

[].tap { |array| array < queue.pop until queue.empty? }