The source code to store items into the hash collection is given below. The given program is compiled and executed on Windows 10 Operating System successfully.
# Ruby program to store items
# into hash collection
hash = {"101" => "Arun", "102" => "Sumit"};
hash.store("103", "Mukesh");
hash.store("104", "Mohit");
puts "Hash elements: ",hash;
In the above program, we created a hash collection to store student information. Then we used the store() method to add items into the hash collection and printed the result.
Program/Source Code:
The source code to store items into the hash collection is given below. The given program is compiled and executed on Windows 10 Operating System successfully.
Output:
Explanation:
In the above program, we created a hash collection to store student information. Then we used the store() method to add items into the hash collection and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer