Skip to content

Instantly share code, notes, and snippets.

@tbrowder
Last active March 9, 2017 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbrowder/62e22837715f749986983491655ef8fe to your computer and use it in GitHub Desktop.
Save tbrowder/62e22837715f749986983491655ef8fe to your computer and use it in GitHub Desktop.
named-param-with-constraint
#!/usr/bin/env perl6
foo;
sub fmt($fmt) {
my token fmt { ^ :i a|b $ }
!$fmt.defined || $fmt ~~ &fmt
}
sub foo {
if $fmt.defined {
say "fmt = $fmt"
}
else {
say "fmt = undefined"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment