3 ms·
I'll say Elixir isn't perfect. There are a few annoying bits that won't be changed due to backwards compatibility, that 98% of people won't run into. For exam
by dnautics 7y ago
I'll say Elixir isn't perfect. There are a few annoying bits that won't be changed due to backwards compatibility, that 98% of people won't run into. For example:
a = [foo: "bar", foo: "baz"]
Keyword.get(a, :foo) #==> gives you "bar"
a[:foo] #==> gives you "bar"
my_struct = struct(SomeStructWithFoo, a)
my_struct.foo #==> gives you "baz"
But really, this minor, minor inconsistency is near the top of my list of complaints, so... Take that into consideration.
Also, if you start coding in Elixir a lot, you will write better Javascript by importing good practices in from Elixir.
- 1_player 7y agoWhat's the problem there? A map has unique keys, a keyword list is just a list of {atom, term}, so there might be duplication. They are similar but they are not the same thing and are not to be used in the same places.
- dnautics 7y agoThe problem is that it violates the principle of least surprise. Thankfully this sort of thing is not rampant in Elixir, and I discovered the example only after something like 50k lines of very joyful code.