Skip to content

Disambiguate S4 dispatch with subtraction and two Period/Duration objects #994

@DavisVaughan

Description

@DavisVaughan

We currently get a once per session warning with subtraction when you have two Period or two Duration objects. This is because we have a method for <ANY> - <Period> and <Period> - <ANY> and it doesn't know which to choose.

library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union

x <- years(4)
y <- dyears(4)

x - x
#> Note: method with signature 'Period#ANY' chosen for function '-',
#>  target signature 'Period#Period'.
#>  "ANY#Period" would also be valid
#> [1] "0S"

x - x
#> [1] "0S"

y - y
#> Note: method with signature 'Duration#ANY' chosen for function '-',
#>  target signature 'Duration#Duration'.
#>  "ANY#Duration" would also be valid
#> [1] "0s"

y - y
#> [1] "0s"

Created on 2021-09-21 by the reprex package (v2.0.0.9000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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