erlang 中的哈希符号有什么作用?
erlang 中的哈希符号有什么作用?
record_to_string(#roster{us = {User, _Server},
jid = JID,
name = Name,
subscription = Subscription,
ask = Ask,
askmessage = AskMessage}) ->
Username = ejabberd_odbc:escape(User).
....
.
What does the hash sign do in erlang?
record_to_string(#roster{us = {User, _Server},
jid = JID,
name = Name,
subscription = Subscription,
ask = Ask,
askmessage = AskMessage}) ->
Username = ejabberd_odbc:escape(User).
....
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
它们与记录一起使用。
They're used alongside records.
只是为了完整性(以防有人在谷歌上搜索“Erlang Hash”):
哈希符号也可以用于定义 具有任意基数的整数,如
Just for completeness (in case someone googles "Erlang Hash"):
The hash symbol can also be used to define an integer with an arbitrary base, as in
它们与 Erlang 中的记录相关。事实上,Erlang 中的创建、访问和更新记录等每个操作都是使用 # http: //20bits.com/articles/erlang-an-introduction-to-records/
They are related to Records in Erlang. Infact every operation like creation,accessing and updating records in Erlang are done using # http://20bits.com/articles/erlang-an-introduction-to-records/
如果一条记录是这样定义的:
您可以通过多种方式使用哈希来访问该记录,其中:
If a record is defined like this:
You can use the hash to access the record in various ways, among which:
正如之前的答案所指出的,它们不仅是记录语法和数字基本表示的一部分,从 Erlang R17 开始,它们还用于映射。 Map是R17中引入的新的键值数据类型,它们表示为:#{Key =>;值,... }
我认为地图上最好的信息来源是此链接。然而,在候选版本 1 中,似乎并未实现其中描述的所有功能。
As well as being part of the syntax for records and base denotation in numbers as previous answers have pointed out, as of Erlang R17, they are also used for maps. Map is a new key-value datatype introduced in R17 and they are expressed as: #{ Key => Value, ... }
I think the best source of information on maps is this link. However, in release candidate 1 it seems not all functionality described there is implemented.
正如其他答案所述,哈希符号用于处理 erlang 中的记录。这是一篇更详细地解释语法的文章。
http://www.techtraits.com/Programming/2011/ 06/11/erlang 记录/
The Hash sign is used to work with records in erlang as noted by other answers. Here is an article that explains the syntax in a bit more detail.
http://www.techtraits.com/Programming/2011/06/11/records-in-erlang/