我听说通过代码中的元组指定记录是一种不好的做法:我应该始终使用记录字段(#record_name{record_field = something}
)而不是简单元组{record_name, value1, value2, something}
。如何匹配ets:匹配Erlang中的记录?
但是,如何将记录与ETS表匹配?如果我有记录的表,我只能配合以下几点:
ets:match(Table, {$1,$2,$3,something}
很明显,一旦我添加了一些新的领域,以记录定义这种模式匹配将停止工作。
相反,我想用这样的:
ets:match(Table, #record_name{record_field=something})
不幸的是,它返回一个空列表。