You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My understanding is that whilst this is the most common usage, it's also only able to be used if the keys are atoms. Is it worth mentioning that this is a possible syntax so that beginners who see other resources are not confused?
The text was updated successfully, but these errors were encountered:
iteles
added
the
discuss
Share your constructive thoughts on how to make progress with this issue
label
Aug 14, 2017
It is a really small syntax transformation, so an explanation would not take up much space, but explaining it will make the exposition that little bit smoother, and better integrated with other resources, so I see no downside, but a clear if small upside: it often helps to first see what a shortcut is, well, shortcutting.
My basic understanding is that the shortcut is a clearer sign of intent, something like the direct analogy of Javascript object literals, whereas the first form is a more general construction, that of a dictionary where the keys are not always/necessarily considered names. In my mind it is the role that atoms play in Elixir as literal names that is the pattern that is of importance and interest.
iteles
added
in-progress
An issue or pull request that is being worked on by the assigned person
and removed
discuss
Share your constructive thoughts on how to make progress with this issue
labels
Aug 15, 2017
I'm a bit late on this, but I definitely agree that a brief description of the differences between the two pieces of syntax would be a really good addition, especially considering the different ways to access the keys dependant on the type.
I definitely ran into confusion when trying to access values in the map literals with map.key rather htan pattern matching.
Re-learning elixir and I sat and stared at the last of the 3 iex lines for 5 minutes (from Dave Thomas' Programming Elixir 1.6 book), wondering why it was different before I figure out that this was shortcut syntax for the last line which is a map of atoms (rather than strings or tuples for example):
In most beginner learning resources I have seen, map literals are presented as:
In this repo, we dive straight into using the shortcut for key/value maps (https://github.com/dwyl/learn-elixir#maps).
My understanding is that whilst this is the most common usage, it's also only able to be used if the keys are atoms. Is it worth mentioning that this is a possible syntax so that beginners who see other resources are not confused?
The text was updated successfully, but these errors were encountered: