I am new to Erlang. I just want to reassign a value to a string variable:
get_alert_body(Packet) ->
BodyElement = element(8,Packet),
Body = "my text",
Els = xmpp:get_els(Packet),
lists:foreach(fun(El) ->
ElementName = io_lib:format("~s",[xmpp:get_name(El)]),
IsFile = string:equal(ElementName,"fileType"),
if
IsFile ->
FileType = fxml:get_tag_cdata(El),
IsPhoto = string:equal(FileType,"photo"),
IsVideo = string:equal(FileType,"video"),
if
IsPhoto ->
%% if it gets to this I would like to return "my photo"
Body = "my photo";
IsVideo ->
%% else if it gets to this I would like to return "my video"
Body = "my video";
true ->
%% otherwise I would like to return "my text"
ok
end;
true ->
ok
end
end, Els),
Body.
But I get this error:
error,{badmatch,"test2"}
Even if I do somthing like:
A = "test1",
A = "test2",
I get the same error.
I would appreciate your help.