What is the closest thing in Erlang to hashes?
What I wanted was a way to pass arguments into functions which resembled a ruby hash map. Although maybe this is a bad fit for Erlang, I'm not sure yet
In Ruby I often used hashes like:
{"a"=>100, "b"=>200}
: What is the closest thing in Erlang?
Update: I have since found this开发者_StackOverflow中文版:
http://20bits.com/articles/erlang-an-introduction-to-records/
Is using records a good candidate?
proplists, dicts, or gb_trees.
Erlang R17A will include map data structure.
ETS and DETS tables are true hash tables unlike a dict. DETS are for disks storage while ETS are in memory. They are the building blocks for the Mnesia database.
Here You are: dict - Key-Value Dictionary
Post scriptum: I have googled this within 30s so I think You could avoid this asking question ;-)
Edit: To defend my answer:
from_list(List) -> Dict
Types:
List = [{Key, Value}]
Dict = dictionary()This function converts the key/value list List to a dictionary.
This is a quotation from my link. So You can create hashes exactly the same way as when You use proplists.
精彩评论