我有以下带有此错误的代码:
10> clients_size:init().
{state,[]}
11> clients_size:size().
** exception error: bad argument
in function length/1
called as length(2)
in call from orddict:size/1 (orddict.erl, line 65)
in call from clients_size:size/0 (clients_size.erl, line 10)
clients_size.erl
-module(clients_size).
-export([init/0, size/0]).
-record(state, {clients}).
init() ->
#state{clients=orddict:new()}.
size()->
Size_of = orddict:size(#state.clients),
io:format("size ~p ~n ",[Size_of]).
我知道它是空的,但我仍然认为它会显示 0。