[erlang-questions] Question about ETS documentation
Mon Mar 31 05:14:30 CEST 2014
Pos refers to a position in the stored tuple. ets:lookup_element returns
only one of the values from the tuple, as opposed to ets:lookup which
returns the tuple in its entirety (in a list for compatibility with
One reason you might prefer lookup_element as opposed to lookup is that
it's slightly cheaper to copy from the table (as you're not copying as much
data), but it's also generally useful as a shorthand for retrieving one
piece of the stored tuple so you don't have to bind the entire return value.
If I recall correctly, lookup_element, update_element, and update_counter
only work with tables of type set or ordered_set.
On Sun, Mar 30, 2014 at 6:45 PM, Yves S. Garret
> I've been reading this documentation:
> What I have a hard time figuring out is what the Pos means. Why would it
> be needed at all? I'm looking at this code:
> Cx_PId = ets:lookup_element(IdsNPIds, Cx#cortex.id, 2),
> And I have no idea what this and why have it there. I've already
> specified the element that we're searching for, why the position? Does the
> position refer to the element that's located inside of the return value?
> As in, I want the 2nd element from the return value?
> Thanks in advance.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions