Ruby | Range size() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The size() is an inbuilt method in Ruby returns the size of the range. It returns the number of elements in the range. Syntax: range1.size() Parameters: The function accepts no parameter. Return Value: It returns the number of elements in the range. Example 1: Ruby # Ruby program for size() # method in Range # Initialize range range1 = (0..10) # Prints the size element puts range1.size() Output: 11 Example 2: Ruby # Ruby program for size() # method in Range # Initialize range range1 = (4..98) # Prints the size of elements puts range1.size() Output: 95 Comment More infoAdvertise with us Next Article Ruby | Range to_a() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Range-class Similar Reads Ruby | Range to_s() function The to_s() is an inbuilt method in Ruby returns a string containing the given range. Syntax: range1.to_s() Parameters: The function accepts no parameter. Return Value: It returns a string containing the range. Example 1: Ruby # Ruby program for to_s() # method in Range # Initialize range range1 = (0 1 min read Ruby | Queue size() function The size() is an inbuilt function in Ruby returns the current size of the Queue or the number of objects present in it. Syntax: q_name.size() Parameters: The function does not takes any parameter. Return Value: It returns the number of elements in the queue. Example 1: CPP #Ruby program for size() f 1 min read Ruby | Range to_a() function The to_a() is an inbuilt method in Ruby returns an array containing the numbers in the given range. Syntax: range1.to_a() Parameters: The function accepts no parameter. Return Value: It returns an array containing all the numbers. Example 1: Ruby # Ruby program for to_a() # method in Range # Initial 1 min read Ruby | Range new() function The new() is an inbuilt method in Ruby returns a new range of numbers. Syntax: range1.new(first, last) Parameters: The function accepts first and last which is the range that is to be created. Return Value: It returns the range of numbers. Example 1: Ruby # Ruby program for new() # method in Range # 1 min read Ruby | Range end() function The end() is an inbuilt method in Ruby returns the last element of the given range. Syntax: range1.end() Parameters: The function accepts no parameter Return Value: It returns the last element of the given range. Example 1: Ruby # Ruby program for end() method in Range # Initialize range range1 = (0 1 min read Ruby | SizedQueue new() function The new() is an inbuilt function in Ruby creates a new SizedQueue of the given name. Syntax: q_name = SizedQueue.new() Parameters: The function does not takes any parameter. Return Value: It creates a new SizedQueue. Example 1: CPP #Ruby program for new () function in SizedQueue #Create a new SizedQ 1 min read Like