How does pattern matching with structs work?

I understand your pattern matching snippet, and in fact that is what I would expect to work.

However, because structs are matched in this manner:

def may_attend_after_party(attendee = %Attendee{}) do
    attendee.paid && attendee.over_18
end

and because %Attendee{} evaluates to %Attendee{name: "", over_18: true, paid: false} I expected the other behaviour to work.

However @ityonemo has given a very concise answer about why this works and @Eiji has provided an amazing demonstration of the fact.

Thanks a lot! This was my first interaction with the Elixir community, and makes me very happy to be a part of it :smile: