Ruby | Struct to_s() function Last Updated : 06 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The to_s() is an inbuilt method in Ruby that returns a string with the value of the particular struct. Syntax: struct_name.to_s() Parameters: The function does not accepts any parameter. Return Value: It returns the value of struct. Example 1: Ruby # Ruby program for to_s method in struct # Include struct animals = Struct.new(:name, :speciality , :found_in) # initialize values detail = animals.new("labrador", "bark" , "Newfoundland") # to_s used puts detail.to_s Output: struct name="labrador", speciality="bark", found_in="Newfoundland" Example 2: Ruby # Ruby program for to_s method in struct # Include struct animals = Struct.new(:name) #initialize values detail = animals.new("golden retriever") #to_s used puts detail.to_s Output: struct name="golden retriever" Comment More infoAdvertise with us Next Article Ruby | Struct to_s() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Struct-class Similar Reads Ruby | Struct to_a() function The to_a() is an inbuilt method in Ruby that returns an array with the value of the particular struct. Syntax: struct_name.to_a[integer] Parameters: The function accepts an integer parameter which specifies the index of the struct value to be returned. Return Value: It returns the value of struct. 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 size() function The size() is an inbuilt method in Ruby that returns the total number of members present in struct. Syntax: struct_name.size() Parameters: The function does not accepts any parameter. Return Value: It returns the integer specifying the members of struct. Example 1: Ruby # Ruby program for size metho 1 min read Ruby | Time to_s function Time#to_s() : to_s() is a Time class method which returns the string representation of the time. Syntax: Time.to_s() Parameter: Time values Return: the string representation of the time. Example #1 : Ruby # Ruby code for Time.to_s() method # loading library require 'time' # declaring time a = Time.n 2 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