Skip to content

Instantly share code, notes, and snippets.

@systra
Created November 24, 2011 10:22
Show Gist options
  • Save systra/1391044 to your computer and use it in GitHub Desktop.
Save systra/1391044 to your computer and use it in GitHub Desktop.
Options merge
-module(opts_utils).
-export([merge_opts/2]).
%% Sample use:
%% Defaults = [{host,"localhost"},
%% {password, []},
%% {port,5432},
%% {password,[]},
%% {username,"test"},
%% {database,"test"},
%% {schema,"public"}].
%% merge_opts([{password, "topsecret"}], Defaults).
%%
merge_opts(Opts, Defaults) ->
SOpts = lists:ukeysort(1, proplists:unfold(Opts)),
proplists:normalize(lists:ukeymerge(1, SOpts, Defaults), []).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment