[erlang-questions] Silly question: if vs pattern matching
Joel Reymont
joelr1@REDACTED
Mon Feb 5 23:32:40 CET 2007
process(String, Env) ->
{Tree, _} = xmerl_scan:string(String),
Closures = visit(Tree),
Tree1 = render(Closures, Env),
Tree2 = if
is_list(Tree1) ->
lists:flatten(Tree1);
true ->
[Tree1]
end,
XML = xmerl:export_simple(Tree2, xmerl_xml,
[#xmlAttribute{name = prolog,value =
""}]),
lists:flatten(XML).
I don't particularly like the "if" above. It just doesn't seem very
Erlangish to me and I would rather replace it with pattern matching.
The silly question is...
Is there any performance benefit or drawback to using pattern
matching as opposed to an "if"?
Thanks, Joel
--
http://wagerlabs.com/
More information about the erlang-questions
mailing list