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

Example 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

#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

chevron_right


Output:

3
2

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

#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

chevron_right


Output:

3
4

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

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.