How to handle Erlang records from Elixir

Asked 2 years ago, Updated 2 years ago, 75 views

When using Erlang's record, I learned that I should use Record.extract, but it will be quite long.

 iex(1)>require Record
nil

iex(2)>r=Record.extract(:sctp_initmsg, from_lib: "kernel/include/inet_sctp.hrl")
[num_ostreams::undefined, max_instreams::undefined, max_attempts::undefined,
max_init_timeo: : undefined ]

Is there any other way besides writing this every time? I hope there is something like include that you can write once.

erlang elixir

2022-09-29 21:47

1 Answers

Selfless, but while I was looking for something else, I happened to find the correct (?) use case.
(Source: https://stackoverflow.com/questions/17345939/elixir-and-erlang-records-pattern-matching)

defrecord:xmlText, Record.extract(:xmlText, from_lib:"xmerl/include/xmerl.hrl") 

Instead of using Record.extract/2 every time you want to use a record, you feed it to the defrecord.


2022-09-29 21:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.