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).
....
.
They're used alongside records.
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
16#deadbeef = 3735928559.
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:
-record(record_name, {first_field, second_field}).
You can use the hash to access the record in various ways, among which:
% create a new record and put it in a variable
Record = #record_name{first_field = 1, second_field = 2},
% get only the second_field of Record
Field = Record#record_name.second_field,
% create a new record from Record, but with a different first_field
Record2 = Record#record_name{first_field = 5}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With