Skip to content

Zero-input constructors should return zero-length objects #707

@hadley

Description

@hadley

Rather than an error, as currently:

library(lubridate)

duration()
#> Error in duration(): No valid values have been passed to 'duration' constructor
period()
#> Error in period(): No valid values have been passed to 'period' constructor
interval()
#> Error in tz(start): argument "start" is missing, with no default

This makes more similar in behaviour to base R

integer()
#> integer(0)
factor()
#> factor(0)
#> Levels:

And this property is taken advantage of in vctrs

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementwipwork in progress

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions