17 Sep 2021   ruby


Calling #clear on a Thread::Queue will remove all objects from that queue

q = Queue.new
42.times { q << 1 }
q.size == 42
=> true

q.clear
q.size == 0
=> true