Ruby - Hashes
Which of the following is the correct syntax to use
dig on a hash h = {a: {b: 2}} to get the value 2?dig on a hash h = {a: {b: 2}} to get the value 2?dig method is called with arguments representing the nested keys or indexes, separated by commas inside parentheses.h.dig(:a, :b), which is the correct syntax. h.dig[:a][:b] uses square brackets incorrectly. h[:a].dig(b) uses b without the leading colon :, causing NameError. h.dig(:a).dig(b) chains dig calls unnecessarily and uses b without :, causing NameError.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions