Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created March 29, 2017 14:29
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 zoffixznet/a79f2825a67338f04cfbbd5a7897124d to your computer and use it in GitHub Desktop.
Save zoffixznet/a79f2825a67338f04cfbbd5a7897124d to your computer and use it in GitHub Desktop.
class Narrow { }
class Middle is Narrow { }
class Wide is Middle { }
multi foo (Narrow $v) { say "Narrow ", $v; $v.^name.uc }
multi foo (Middle $v) { say "Middle ", $v; $v.^name.uc }
multi foo (Wide $v) { say "Wide ", $v; nextwith 41; $v.^name.uc }
multi foo (Any $v where .is-prime) { say "Prime ", $v; $v.^name.uc }
multi foo (Any $v where not .is-prime) { say "Non-Prime ", $v; $v.^name.uc }
foo Wide; # OUTPUT: Wide (Wide)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment