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 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 |
chevron_right
filter_none
Output:
nagpur orange
Example 2:
# 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 |
chevron_right
filter_none
Output:
labrador bark Newfoundland
Recommended Posts:
- Ruby | Struct to_s() function
- Ruby | Struct eql?() function
- Ruby | Struct length() function
- Ruby | Struct members() function
- Ruby | Struct size() function
- Ruby | Struct to_a() function
- Ruby | Struct values_at() function
- Ruby | Struct filter() function
- Ruby | Struct each() function
- Ruby | Struct == function
- Ruby | Struct inspect() function
- Ruby | Struct Class
- Ruby | Hash values function
- Ruby | Matrix cofactor() function
- Ruby Integer odd? function with example
- Ruby Integer div() function with example
- Ruby | Symbol to_s function
- Ruby | Set replace() function
- Ruby | Set reset() function
- Ruby | Array Concatenation using (+) function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

