pop {container} | R Documentation |
Get and Remove Element
Description
Search and return an element and remove it afterwards from the object. If the element is not found, signal an error.
Usage
ref_pop(.x, ...)
ref_popleft(.x, ...)
## S3 method for class 'Deque'
ref_pop(.x, ...)
## S3 method for class 'Deque'
ref_popleft(.x, ...)
## S3 method for class 'Container'
ref_pop(.x, index, ...)
## S3 method for class 'dict.table'
ref_pop(.x, index, ...)
Arguments
.x |
any |
... |
additional arguments to be passed to or from methods. |
index |
|
Details
All functions work by reference, that is, the original object is altered.
ref_pop(.x)
tries to access specific values.
ref_popleft(.x)
pops first element of a Deque
.
Value
For Deque
the first (ref_popleft
) or last (ref_pop
) element of
the deque after it was removed.
For Container
the value at the given index after it was removed from
the Container
object. If index
is not found, an error is raised.
For dict.table
, returns the column at the given index
after it was
removed from the dict.table
. If column does not exist, an error is raised.
See Also
Examples
# Deque
d = deque(1, 2, 3)
ref_pop(d)
ref_popleft(d)
try({
ref_pop(deque()) # pop at empty Deque
})
# Container
co = container(a = 1, b = 1:3, d = "foo")
ref_pop(co, "b")
ref_pop(co, 1)
try({
ref_pop(co, "x") # index 'x' not found
})
# dict.table
dit = dict.table(a = 1:3, b = 4:6)
ref_pop(dit, "a")
ref_pop(dit, 1)
try({
ref_pop(dit, "x") # index 'x' not found
})