我有一本字典,我用它来存储使用参数名的另一本字典。

我收到右侧不匹配错误。

这是我的代码

handle_cast({setState, Id}, State) ->
Id0 = dict:new(),
DQueue = queue:new(),
UQueue = queue:new(),
Id1 = dict:store(dQueue, [DQueue], Id0),
Id2 = dict:store(uQueue, [UQueue], Id1),
Id3 = dict:store(dSpeed, [], Id2),
Id4 = dict:store(uSpeed, [], Id3),
D = dict:store(Id, [Id4], State),
State = D,
{noreply, State};


我不确定错误来自哪里。我认为这可能是因为我将Id作为键存储在主词典中,而新的内部词典作为值。

我需要内部字典的名称作为Id的值,因为其中将有许多字典,以后我需要通过Id访问它们。

我是否正确设置了词典? erlang是否允许字典保存字典?

谢谢

最佳答案

如果不尝试代码,我敢打赌,考虑到State = D已绑定在函数头中,则在执行State时会出现不匹配的情况。最重要的是,除非抄写/粘贴错误的函数,否则USpeedDSpeed应该是未定义的。

关于dictionary - 在Erlang中将字典存储在字典中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4340536/

10-12 07:32