Ruby | Struct values() function Last Updated : 06 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The values() 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 struct value to be returned. Return Value: It returns the value of struct. Example 1: Ruby # Ruby program for values method in struct # Include struct place = Struct.new(:name, :speciality) # initialize values detail = place.new("nagpur","orange") # print value puts detail.values Output: nagpur orange Example 2: Ruby # Ruby program for values method in struct # Include struct animals = Struct.new(:name, :speciality , :found_in) # initialize values detail = animals.new("labrador", "bark" , "Newfoundland") # values used puts detail.values Output: labrador bark Newfoundland Comment More infoAdvertise with us Next Article Ruby | Struct values() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Struct-class Similar Reads Ruby | Struct values_at() function The values_at() is an inbuilt method in Ruby that returns an array with the struct members values. Selector can be of two types: Integer or Range offset. Syntax: struct_name.values_at(range) Parameters: The function takes a single parameter range which will specify the start and end of the struct me 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 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 to_s() function 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 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