Elixir 1.8.1 (compiled with Erlang/OTP 20)
Ubuntu 18.04
Trying to create a new MapSet named T as in the docs.
Current output is:
iex(1)> T = MapSet.new()
** (MatchError) no match of right hand side value: #MapSet<[]>
(stdlib) erl_eval.erl:453: :erl_eval.expr/5
(iex) lib/iex/evaluator.ex:257: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:237: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:215: IEx.Evaluator.eval/3
(iex) lib/iex/evaluator.ex:103: IEx.Evaluator.loop/1
(iex) lib/iex/evaluator.ex:27: IEx.Evaluator.init/4
If I follow the docs, apparently this structure is not being created correctly. Is it something wrong with my Elixir/Erlang version?
In case the docs need updates, I would be happy to submit a pull request or something like that :)
Hey @LucianaMarques, the problem happening here is that you're assigning the result of MapSet.new() to T. As you might know, in Elixir and Erlang = is for pattern matching and assignment, but in Elixir T is a module name (that is, an atom). You might come from Erlang and that's why you used T or it might just be a typo. In any case, the MatchError is happening because the mapset doesn't match with the atom T.
This will work:
iex> t = MapSet.new()
#MapSet<[]>
Hi @LucianaMarques!
Variables in Elixir must start in lowercase. Therefore, T is not a variable, but rather an atom. So you are trying to match two values that can never be equal, like this:
iex(1)> 1 = 2
** (MatchError) no match of right hand side value: 2
Which is why you get such error. If you rename the variable to t (lowercase), then it should work!
Wow guys, thank you for such a quick response! It's working now 馃榿
Most helpful comment
Hi @LucianaMarques!
Variables in Elixir must start in lowercase. Therefore,
Tis not a variable, but rather an atom. So you are trying to match two values that can never be equal, like this:Which is why you get such error. If you rename the variable to
t(lowercase), then it should work!