re: Which Data Structure Should I Use? An Elixir Cheat Sheet VIEW POST


Man, you know what I find really hard? No joke -- it's the syntax/writing differences between maps and structs and things with atom keys or string keys and accessing with a dot or brackets or whatever. I swear I always pick the wrong one and I just cannot keep straight in my head which is which and how to tell what I should be using.


Its easy, if the keys are atoms than with . :) If they are with String you cannot access with . In my head the two dots that are used for atom declaration are reminding me that i must use . while trying to access. One more thing worth mention is that if you try to access something with . and there is no such key it will give you error - key ... not found in .. but if you use strings as keys even the key is not there, it will just return nil it will not give you error

Code of Conduct Report abuse