Ruby | Struct length() function Last Updated : 18 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 # Include struct Student = Struct.new(:name, :address, :dept) # initialize values detail = Student.new("Shizuka", "Washington", "CSE") # length used puts detail.length Output: 3 Example 2: Ruby # Ruby program for length method in struct # Include struct Student = Struct.new(:name, :address, :dept , :project) # initialize values detail = Student.new("Vishwa", "Hyderabad", "CSE" , "IOT") # length used puts detail.length Output: 4 Comment More infoAdvertise with us Next Article Ruby | Struct length() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Struct-class Similar Reads Ruby | Set length() function 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 leng 1 min read Ruby | Struct == function The == is an inbuilt method in Ruby returns true if other has the same struct subclass and has equal member values. Syntax: struct1 == struct2 Parameters: The function accepts no parameter. Return Value: It returns boolean value true if both the given ranges are equal, else it returns false. Example 1 min read Ruby | Struct inspect() function The inspect() is an inbuilt method in Ruby that returns a string with the value of the particular struct. Syntax: struct_name.inspect() Parameters: The function does not accepts any parameter. Return Value: It returns the value of struct. Example 1: Ruby # Ruby program for inspect method in struct # 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 | Struct members() function The members() is an inbuilt method in Ruby that returns an array of symbols containing the struct members. Syntax: struct_name.members() Parameters: The function does not accepts any parameter. Return Value: It returns the array with struct members. Example 1: Ruby # Ruby program for members method 1 min read Like