Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created August 25, 2022 23:30
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 gfldex/337fb1f3d8a8bcec0ccf4556124ff2b1 to your computer and use it in GitHub Desktop.
Save gfldex/337fb1f3d8a8bcec0ccf4556124ff2b1 to your computer and use it in GitHub Desktop.
use v6.*;
class Type is Int { }
subset Even of Type where * %% 2;
Type.^add_method('COERCE', my method COERCE(|) {
my Even $retval = 42
});
sub foo(Even() $_) { .&dd }
foo ‘answer’;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment