[erlang-questions] Good form
Donald Steven
t6sn7gt@REDACTED
Thu Mar 14 23:12:35 CET 2019
Sometimes, when a variable is bound then used only once in a function
call, it seems easier just to just use what it is bound to directly in
the function call, bypassing the first step.
Here's an example:
getSound(Event)
->element(evaluate:probableElement(evaluate:probabilities(maps:get(elementTag,
Event))),
hd(lists:nth(maps:get(templateTag, Event),
agitatedSoundResources(maps:get(scalarTag, Event), maps:get(registerTag,
Event), maps:get(transpositionTag, Event))))).
Alternatively, I could have declared, for example, a raft of variable
like ElementNumber, ElementTag, TemplateTag, etc.
I realize that this all-in-one-compact version tends towards inscrutabel
c code liek &X++ ?.
How do you approach the temptation to avoid discrete steps in favor of
compactness?
Thanks.
Don
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190314/af8b43ec/attachment.htm>
More information about the erlang-questions
mailing list