我写了这段代码:
Player = t:user(List),
CatchAll = [{'_', [], ['$_']}],
NameList = mnesia:dirty_select(player, CatchAll),
if
(length(NameList) < 4)->
T3 = fun() ->
X3 = #player{name = Player},
mnesia:write(X3)
end,
mnesia:transaction(T3),
NameList1 = mnesia:dirty_select(player, CatchAll),
?INFO_MSG("1The value of NameList1 is ~p~n", [NameList1]),
ok;
(length(NameList) == 4)->
?INFO_MSG("2The value of NameList is ~p~n", [NameList])
end,
在这里,每次调用一个模块t:user我得到一个名字,我已经存储在Player中,并希望继续存储这些名称,直到有4个,但每次我运行这个,我得到一个空值名单列为[],而不是填充玩家名称的列表。
关于为什么会发生这种情况的任何想法?