Ruby | Set length() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The length() is an inbuilt method in Ruby returns the size of the Set. It returns the number of elements in the set. Syntax: s1_name.length() Parameters: The function does not accepts any parameter. Return Value: It returns the size of the set. Example 1: Ruby # Ruby program to illustrate # the length method # requires the set require "set" s1 = Set[16, 8, 3, 5, 2] # length method used puts s1.length() Output: 5 Example 2: Ruby # Ruby program to illustrate # the length method # requires the set require "set" s1 = Set[1, 2, 5] # length method used puts s1.length() Output: 3 Comment More infoAdvertise with us Next Article Ruby | Set length() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Set-class Similar Reads Ruby | Struct length() function The length() is an inbuilt method in Ruby that returns the number of members in struct. Syntax: struct_name.length() Parameters: The function does not accepts any parameter. Return Value: It returns the number of members in the struct. Example 1: Ruby # Ruby program for length method in struct # Inc 1 min read Ruby | Symbol length function Symbol#length() : length() is a Symbol class method which returns the length of the symbol. Syntax: Symbol.length() Parameter: Symbol values Return: the length of the symbol Example #1 : Ruby # Ruby code for Symbol.length() method # declaring Symbol a = :aBcDeF # declaring Symbol b = :"\u{e4 f6 2 min read Ruby | SizedQueue length() function The length() is an inbuilt function in Ruby returns the current length of the SizedQueue or the number of objects present in it. It does not returns the pre-defined size of the SizedQueue Syntax: sq_name.length() Parameters: The function does not takes any parameter. Return Value: It returns the num 1 min read Ruby | Array length() function Array#length() : length() is a Array class method which returns the number of elements in the array. Syntax: Array.length() Parameter: Array Return: the number of elements in the array. Example #1 : Ruby # Ruby code for length() method # declaring array a = [18, 22, 33, nil, 5, 6] # declaring array 1 min read Ruby | Queue length() function 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: CPP #Ruby program for le 1 min read Like