VOOZH about

URL: https://www.geeksforgeeks.org/ruby/ruby-queue-clear-function/

⇱ Ruby | Queue clear() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Queue clear() function

Last Updated : 12 Jul, 2025
The clear() is an inbuilt function in Ruby clears the queue and makes it size to be zero again. We can re-insert objects again to it.
Syntax: q_name.clear() Parameters: The function does not takes any element. Return Value: It clears the queue and does not returns anything.
Example 1: Output:
5
0
Example 2: Output:
0
Reference: https://devdocs.io/ruby~2.5/queue#method-i-clear
Comment