VOOZH about

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

⇱ Ruby | Queue shift() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Queue shift() function

Last Updated : 12 Jul, 2025
The shift() is an inbuilt function in Ruby returns the element in the front of the queue and removes it from the queue.
Syntax: q_name.shift() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the queue and removes it from the queue.
Example 1: Output:
5
6
Example 2: Output:
12
21
Reference: https://devdocs.io/ruby~2.5/queue#method-i-shift
Comment