
Last chance! 50% off unlimited learning
Sale ends in
vec_ptype_inner()
finds the inner type of a single vector.
vec_ptype_inner_common()
finds the common inner type of multiple
vectors.
vec_ptype_inner(x)vec_ptype_inner_common(..., .ptype = NULL)
A vector.
Vectors to determine the common inner type of.
If not NULL
, this overrides the common inner type of ...
.
The inner type is a 0-size, 0-shape prototype that represents the
"inner" type of x
. The return value is essentially the
object form of typeof()
.
For complex types, a method should be written that returns an empty inner type of that input with no shape or size. If that complex type can have multiple inner types, the method should be written so that it returns the correct inner type of the current input. The return value should not have the class of the classed input.
The common inner type is useful alongside vec_cast_inner()
.
For example, rray_bind()
uses vec_ptype_inner_common()
to determine the common inner type, and then uses
vec_cast_inner()
to cast each of the inputs to the same inner
type before binding them together.
# NOT RUN {
# The inner type of base R atomics uses their constructor
# vec_ptype_inner(1)
# The inner type of an rray is an empty base R object
# vec_ptype_inner(rray(1))
# Find the common inner type of multiple inputs
# (the double type wins, the container types are disregarded)
# vec_ptype_inner_common(1, TRUE, rray(1L))
# }
Run the code above in your browser using DataLab