Ruby | Struct members() function Last Updated : 06 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 in struct # Include struct Student = Struct.new(:name, :address, :dept , :project) #initialize values detail = Student.new("Vishwa", "Hyderabad", "CSE" , "IOT") # members used puts detail.members Output: name address dept project Example 2: Ruby # Ruby program for members method in struct # Include struct Movie = Struct.new(:name, :imdbrating) # initialize values detail = Movie.new("3idiots", 5) # members used puts detail.members Output: name imdbrating Comment More infoAdvertise with us Next Article Ruby | Struct members() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Struct-class Similar Reads Ruby | Set member?() function The member?() is an inbuilt method in Ruby returns true if the set contains the given object. It returns false if it does not contains the given object. Syntax: s1_name.member?(object) Parameters: The function accepts a mandatory parameter object whose presence is to be checked for. Return Value: It 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 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 | 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 | Struct eql?() function The eql?() is an inbuilt method in Ruby returns true if other has the same struct subclass and has equal member values. Syntax: struct1.eql?(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. 1 min read Like