ets

How to access to value in ets?


value = :ets.lookup(:table, key)

So, in example above, when I use ets.lookup i receive a list with map that's contains a key and values. But i want to get values only. What should I do?


Solution

  • You can use ets:lookup_element/3. Doc: https://www.erlang.org/doc/man/ets.html#lookup_element-3

    user = :ets.lookup_element(:users, hash, 2)