match?/2 is a macro, which basically expands into a case/2 expression. So in the first argument its only allowed what would be allowed in a case/2 on the left side of a match.
As far as I remember, match/2 even allowed guards using when for the first argument.
iex(1)> match?(x when is_integer(x), 2)
true
iex(2)> match?(x when is_integer(x), :a)
false
match?/2 is actually a macro that compiles to a case expression. The parameters to match?/2 are a pattern and an expression. So the first param needs to be a pattern.
How can I know if the first map matches with the second (something like map1 = map2)? I realize that even my with doesn’t work because the first part must be a pattern in a match, as you guys explained.
I converted the keyword lists into maps because I could easily check for matches (e.g. one keyword list is a subset of another); for example: %{foo: :bar} = %{foo: :bar, hello: :world}. It’s a characteristic I like about maps. I guess there’s no way to do it as I intended, and maybe it’s then not even worth to convert into a map.