mnesia - Erlang check empty string -
i'm new in erlang development. i'm trying read value of accesstoken mnesia table (stored in 'users' table).
in code i've done:
buser = boss_db:find(users, [{email, 'equals', myemail}]), [{_,_,bemail,bname,bpassword,_,baccesstoken}] = buser, io:format("user details ~n~p~n", [buser]), io:format("access token ~n~p~n", [baccesstoken]), . . i get:
user details [{users,"users-1","mymail@someemail.org","some name","somepassword",'',''}] the lastly field accesstoken , printed as:
access token '' if accesstoken value non empty i'll operation.
how check if accesstoken empty or not?
i tried:
accesstokenlength = length(baccesstoken) if accesstokenlength > 0 -> . . but next error:
error in controller error badarg [{erlang,length,[''],[]} i tried:
case binary_to_list(baccesstoken) =/= [] of true-> false-> but next error:
error in controller error badarg [{erlang,binary_to_list,[''],[]} how check empty status properly?
you pattern match on value
case baccesstoken of '' -> %% empty _ -> %% not empty end and 1 more thing. single quotes in erlang signifies atom. can write starting lover case letter, atom or false or not_empty. utilize more "complex" atom utilize single quote 'this atom'. , '' "empty atom.
and empty binary <<>>.
erlang mnesia
No comments:
Post a Comment