How do you make an inverse hash from an existing hash (swap the keys/value pairs)?
Select one:
a. revise(%original_hash);
b. %swapped_hash = reverse(%original_hash);
c. my %swapped_hash = inverse %original_hash;
d. my %swapped_hash = reverse %original_hash;
Please rate the answer. Feel free to contact me in case any more clarifications required.
Question_01. How do you make an inverse hash from an existing hash (swap the keys/value pairs)?
Answer =>
Hash Explanation:
Hash is a set of key/value pairs. "reverse" to create an inverted hash or to swap the keys/value pairs.
Hash variables are preceded by a percent(%) sign.
Example : %data = ( "Jack" => "John", "Ram" => "Kumar" );
The syntax for inversing a give HASH is as below:
# %ORIGINAL_HASH maps keys to values :
%NEWORIGINAL_HASH = reverse %ORIGINAL_HASH ;
So the answer is: Option B;
=> %swapped_hash = reverse(%original_hash);
Get Answers For Free
Most questions answered within 1 hours.