Array merge in elixir

  1. There are no arrays in Elixir.

  2. You can probably use Enum.zip_with/2. The following should do if I understand you correctly (a2 takes precedennce unless it is nil):

    Enum.zip_with([a1, a2], fn [a, nil] -> a; [_, b] -> b end)