How can I read a tuple key and value in Erlang?
I have this variable:
Params = [<<"TPUIBrowser">>,0,18,
{[{<<"End">>,<<"location-1ÿ">>},{<<"Start">>,<<"location-1">>}]},
null]
and I would like to get the values for <<"End">> and <<"Start">>.
How could I do that in Erlang?
I can do it like this:
[_,_,_,A,_] = Params.
{[{_,B},{_,C}]} = A.
But this feels very verbose and error prone (i.e. when I get sent more params). What would be the best erlang way?
There are functions for this in the lists library. Check out lists:keyfind:
(I assume you know where in
Paramsyou haveA)