In this program, we will create a hash collection. Then we will print the original and inverted hash collection, here we will invert key/value to each other.
The source code to print the inverted hash collection is given below. The given program is compiled and executed on Windows 10 Operating System successfully.
Program/Source Code:
The source code to print the inverted hash collection is given below. The given program is compiled and executed on Windows 10 Operating System successfully.
Output:
Original Hash collection: {"101"=>"Amit", "102"=>"Arun", "103"=>"Sumit"} Inverted hash collection: {"Amit"=>"101", "Arun"=>"102", "Sumit"=>"103"}Explanation:
In the above program, we created a hash collection to store student information. Then we printed the inverted hash collection using the invert() m
need an explanation for this answer? contact us directly to get an explanation for this answer