Chained pattern match

Consider the following code:

%{a_left: a_left} = a_full = %{} = a_full = %{a_right: a_right} = %{a_left: 42, a_right: 42}
#β‡’ %{a_left: 42, a_right: 42}

Is every element in the chain is always matched against the rightmost one? Is there any reference/link/documentation all around describing this behavior? The official doc is pretty concise :slight_smile:

This shows right to left as precedance, so do put everything on the left onto parenthesis starting from the right and youβ€˜ll explicitly see the order of application. Also the pattern match expression will always evaluate to the full matched value. So yes everything will match the rightmost value.


Indeed. I somehow missed that.


1 Like