Created
October 13, 2016 19:00
-
-
Save ajs/079f1f9c7d0cf51e6c8cd9ed745beb30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
class Filename is Str { | |
# Do some filename type stuff, here... | |
} | |
sub MAIN( | |
:$foo is copy where { $foo = Filename.new: :value($foo) } | |
#= A filename argument. | |
) { | |
say $foo.IO.basename; | |
} | |
# The monkey-typing version follows: | |
# use MONKEY-TYPING; | |
# class Filename is Str { | |
# # Do some filename type stuff, here... | |
# } | |
# augment class Str { method Filename(Str:D:) { Filename.new(:value(self)) } } | |
# sub MAIN( | |
# Filename(Str) :$foo | |
# #= A filename argument. | |
# ) { | |
# say $foo.IO.basename; | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment