Skip to content

Instantly share code, notes, and snippets.

@treyharris
Last active January 29, 2020 20:13
Show Gist options
  • Save treyharris/0ce541c07a1f94b41af61207563e7807 to your computer and use it in GitHub Desktop.
Save treyharris/0ce541c07a1f94b41af61207563e7807 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
proto check_type($ --> Str) { * }
multi check_type(uint $var) { return "uint" }
multi check_type(Int $var) { return "Int" }
my uint $ui = 42;
say "Value is $ui"; # Value is 42
say check_type($ui); # uint
say ".^name is {$ui.^name}"; # .^name is Int
say check_type($ui); # uint
# .abs autoboxes
say check_type($ui.abs); # Int
# abs() does not
say check_type(abs $ui); # uint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment