Quiz on Hashes
Explore how to work with Ruby hashes by taking a quiz on key-value pairs, syntax, and methods. This lesson helps beginners understand the practical use of the built-in Hash class in Ruby programming.
We'll cover the following...
We'll cover the following...
Quiz scenario
Consider a hash named dictionary that’s defined as follows:
dictionary = {
:one => 'uno',
:two => 'dos',
:three => 'tres'
}
Answer the following questions about this hash.
Quiz on Hashes
1.
Which statement prints dos?
A.
dictionary['two']
B.
dictionary[:two]
C.
dictionary[:2]
D.
Both B and C
1 / 3