Subject: Re: [erlang-questions] List Question



On 2017年08月07日 月曜日 22:13:23 Andrew McIntyre wrote:
> Hello All,
>
> A Newbie question,
>
> Can I tell the difference Between a List of Strings and a Single
> String?
>
> eg the Value in a List may just be "FT" or it might be ["FT", "ST"]

Using a match this is pretty straight forward.


choose_your_adventure("FT") ->
path_one();
choose_your_adventure(["FT" | Rest]) ->
ok = path_two(),
choose_your_adventure(Rest).

Generally speaking, if your system is the one generating the lists/strings then
it is useful to produce them in a way that is more semantically unambiguous.

-Craig
_______________________________________________
erlang-questions mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-questions
...



Programming list archiving by: Enterprise Git Hosting