Open In App

Ruby | SizedQueue max= function

Last Updated : 09 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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 the current size of the SizedQueue to X.

Example 1:




#Ruby program for max() function in SizedQueue
  
#Create a new SizedQueue q1
sq1 = SizedQueue.new(3)
  
#Prints the max size
          puts sq1.max
  
#Changes the max size
              sq1.max
    = 2
  
#Prints the new max size
      puts sq1.max


Output:

3
2

Example 2:




#Ruby program for max() function in SizedQueue
  
#Create a new SizedQueue q1
sq1 = SizedQueue.new(3)
  
#Prints the max size
          puts sq1.max
  
#Changes the max size
              sq1.max
    = 4
  
#Prints the new max size
      puts sq1.max


Output:

3
4

Reference: https://devdocs.io/ruby~2.5/sizedqueue#method-i-max-3D


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads