Understanding the match operator

Yes, the ultimate bindings are clear :+1: My problem is understanding the nuances.

The article says that reversing the match order:

defmodule Greeter3 do
  def hello(person = %{name: person_name}) do
    IO.puts "Hello, " <> person_name
    IO.inspect person
  end
end

results in a successful match with fred “because each are matching to fred on their own” and later says “Remember that even though it looks like %{name: person_name} = person is pattern-matching the %{name: person_name} against the person variable, they’re actually each pattern-matching to the passed-in argument”.

I read this to mean an expression like this: (person = fred) = (%{name: person_name} = fred) is happening opposed to: person = (%{name: person_name} = fred) although I think the latter is in fact correct.

I’m thinking the reason you can switch the order here is not because they are “matching to fred on their own” but because the %{name: person_name} = fred match, results in the whole map which can be bound to person to the left. Just like what happens with %{a: x} = %{b: y} = %{a: "what", b: "happened"}.

This is what I’m seeking clarity on and find poorly worded.