Ruby Language Queue Converting a Queue into an Array

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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? }


Got any Ruby Language Question?