Created
July 6, 2016 18:52
-
-
Save Lugghawk/f1069442c7cdc7226944de831803c327 to your computer and use it in GitHub Desktop.
Map Merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PMTest do | |
def apply_defaults(json_obj) do | |
Map.merge(json_obj, defaults, fn _,v1,v2 -> | |
case v1 do | |
nil -> v2 | |
_ -> v1 | |
end | |
end) | |
end | |
def defaults do | |
%{def1: "default_one", def2: "default_two", def3: "default_three"} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment