To display only the 'size' from the given array in Ruby, you can use the following code:
main.rb87 chars4 lines
Output:
main.rb15 chars2 lines
In the above code, we first define the array with the given values. Then, we access the first element of the array using array[0]
and further access the 'size' key using [:size]
. Finally, we print the 'size' using puts
and inspect
to display its contents.
Note that the output is in the form of a nested hash, where each key represents the size label (s, m) and its value represents the corresponding size value.
gistlibby LogSnag