On good terms with constants
While building a little helper module to fetch internet radio stations I found myself wanting to provide a constant named parameter. Quite a few methods of DateTime have a named argument when $*TZ
would be wrong. As it turns out, this is really easy in Perl 6.
constant term:<GMT> = timezone => 0; say DateTime.now(|GMT)
The term GMT
is still a Pair
so we have to slip it in but it’s still a bit shorter and more expressive once one gets used to the idea of constant Pair
terms.
Categories: Perl6
Comments (0)
Trackbacks (1)
Leave a comment
Trackback
-
August 15, 2017 at 01:022017.33 In Review | Weekly changes in and around Perl 6