Skip to content

Instantly share code, notes, and snippets.

View daniel-jacob-pearson's full-sized avatar

Daniel Pearson daniel-jacob-pearson

View GitHub Profile
# Deep merge
#
# - Write a function that takes two hashes and returns a new hash containing the
# keys and values from both hashes.
# - Neither input should be modified.
# - If the key exists in both hashes...
# ...merge the values if they are both hashes.
# ...give the values in the second hash (b) precedence otherwise.
def merge(a, b)
# Deep merge
#
# - Write a function that takes two dictionaries and returns a new dictionary
# containing the keys and values from both dictionaries.
# - Neither input should be modified.
# - If the key exists in both dictionaries...
# ...merge the values if they are both dictionaries.
# ...give the values in the second dictionary (b) precedence otherwise.
def merge(a, b):