Ruby | SizedQueue size() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The size() is an inbuilt function in Ruby returns the current size of the SizedQueue or the number of objects present in it. Syntax: sq_name.size() Parameters: The function does not takes any parameter. Return Value: It returns the number of elements in the SizedQueue. Example 1: CPP #Ruby program for size() function in SizedQueue #Create a new SizedQueue q1 sq1 = SizedQueue.new(2) #pushes 5 sq1.enq(5) #pushes 6 sq1.enq(6) #Prints the size puts sq1.size #Pops the element sq1.pop #Prints the size puts sq1.size Output: 2 1 Example 2: CPP #Ruby program for size() function in SizedQueue #Create a new SizedQueue q1 sq1 = SizedQueue.new(3) #Prints the size puts sq1.size #pushes 5 sq1.enq(5) #pushes 6 sq1.enq(6) #pushes 7 sq1.enq(7) #Prints the size puts sq1.size #Pops the element sq1.pop #Prints the size puts sq1.size Output: 0 3 2 Reference: https://devdocs.io/ruby~2.5/sizedqueue#method-i-size Comment More infoAdvertise with us Next Article Ruby | SizedQueue shift() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Collections Ruby SizedQueue-class Similar Reads Ruby | SizedQueue shift() function The shift() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.shift() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the SizedQueue and remove 1 min read Ruby | SizedQueue shift() function The shift() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.shift() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the SizedQueue and remove 1 min read Ruby | SizedQueue shift() function The shift() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.shift() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the SizedQueue and remove 1 min read Ruby | SizedQueue shift() function The shift() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.shift() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the SizedQueue and remove 1 min read Ruby | SizedQueue shift() function The shift() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.shift() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the SizedQueue and remove 1 min read Ruby | SizedQueue max= function The max=() is an inbuilt function in Ruby changes the current capacity of the SizedQueue and sets it into X, where X is given by the user. Syntax: sq_name.max=X() Parameters: The function accepts a single mandatory parameter and changes the current size of the SizedQueue to X. Return Value: It sets 1 min read Like