develooper Front page | perl.perl6.users | Postings from May 2018

Range of Dates

Thread Next
From:
Sean McAfee
Date:
May 1, 2018 20:04
Subject:
Range of Dates
Message ID:
CANan03aKuMuvnu6CGNaY3+YKS6ZF4exLDwuJrCraVXT42SgmJw@mail.gmail.com
Today I wanted to write an infinite sequence of Dates starting from today,
but I accidentally wrote two dots instead of three as I'd intended.  I was
surprised to find that it seems to work as one might expect, eg:

    (Date.today .. *)[7] # one week from today

The online docs say that Ranges are only for numbers and strings, so how is
it that this works?  Is it an accident, or can anything that has a "succ"
method be in a Range, or...?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About