sub infix:<->

Documentation for sub infix:<-> assembled from the following types:

class Range

From Range

(Range) sub infix:<->

multi sub infix:<->(Range:D \rReal:D \v)

Takes an Real and subtract that number to both boundaries of the Range object. Be careful with the use of parenthesis.

say (1..2- 1# OUTPUT: «0..1␤» 
say 1..2 - 1;   # OUTPUT: «1..1␤»

class Date

From Date

(Date) sub infix:<->

multi sub infix:<-> (Date:DInt:D --> Date:D)
multi sub infix:<-> (Date:DDate:D --> Int:D)

Takes a date to subtract from and either an Int, representing the number of days to subtract, or another Date object. Returns a new Date object or the number of days between the two dates, respectively.

say'2016-12-25'-'2016-12-24'); # OUTPUT: «1␤» 
say'2015-12-25'-'2016-11-21'); # OUTPUT: «-332␤» 
say'2016-11-21'- 332;                    # OUTPUT: «2015-12-25␤»

class DateTime

From DateTime

(DateTime) sub infix:<->

multi sub infix:<-> (DateTime:DDuration:D --> DateTime:D)
multi sub infix:<-> (DateTime:DDateTime:D --> Duration:D)

Takes a DateTime to subtract from and either a Duration or another DateTime object. Returns a new DateTime object or the Duration between the two dates, respectively. When subtracting Duration, time zone of the original DateTime is preserved in the returned DateTime object.

say perl -;
# OUTPUT: «␤» 
say, :3600timezone) -;
# OUTPUT: «2015-01-01T00:00:00+01:00␤»