VOOZH about

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

⇱ Ruby | Queue length() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Queue length() function

Last Updated : 12 Jul, 2025
The length() is an inbuilt function in Ruby returns the current length of the Queue or the number of objects present in it.
Syntax: q_name.length() Parameters: The function does not takes any parameter. Return Value: It returns the number of elements in the queue.
Example 1: Output:
2
1
Example 2: Output:
0
3
2
Reference: https://devdocs.io/ruby~2.5/queue#method-i-length
Comment