Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hadley opened this issue Aug 13, 2018 · 2 comments · Fixed by #826
Closed

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

hadley opened this issue Aug 13, 2018 · 2 comments · Fixed by #826
Labels

Comments

@hadley
Copy link
Member

@hadley hadley commented Aug 13, 2018

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

@hadley

This comment has been minimized.

Copy link
Member Author

@hadley hadley commented Aug 13, 2018

Would also make more compatible with new POSIXct() and Date() constructors

@vspinu

This comment has been minimized.

Copy link
Member

@vspinu vspinu commented Aug 15, 2018

Makes sense.

@hadley hadley added the feature label Nov 19, 2019
hadley added a commit that referenced this issue Nov 20, 2019
@hadley hadley added the wip label Nov 20, 2019
vspinu added a commit that referenced this issue Dec 1, 2019
@vspinu vspinu closed this in 2e8e5f6 Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.