Ruby | Struct inspect() function Last Updated : 18 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 # Include struct animals = Struct.new(:name, :speciality , :found_in) # initialize values detail = animals.new("labrador", "bark" , "Newfoundland") # inspect used puts detail.inspect Output: struct name="labrador", speciality="bark", found_in="Newfoundland" Example 2: Ruby # Ruby program for inspect method in struct # Include struct animals = Struct.new(:name) # initialize values detail = animals.new("golden retriever") # inspect used puts detail.inspect Output: struct name="golden retriever" Comment More infoAdvertise with us Next Article Ruby | Struct inspect() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Struct-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 | StringScanner inspect function StringScanner#inspect() : inspect() is a StringScanner class method which returns string that represents the StringScanner object showing different values. Syntax: StringScanner.inspect() Parameter: StringScanner values Return: - the current position - the size of the string - the characters surroun 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 | Symbol inspect function Symbol#inspect() : inspect() is a Symbol class method which returns the string representation of the symbol value. Syntax: Symbol.inspect() Parameter: Symbol values Return: the string representation of the symbol value. Example #1 : Ruby # Ruby code for Symbol.inspect() method # declaring Symbol a = 1 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