Skip to content

Instantly share code, notes, and snippets.

Created July 8, 2012 16:03
Show Gist options
  • Save anonymous/3071483 to your computer and use it in GitHub Desktop.
Save anonymous/3071483 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/p6/rakudo$ cat y
class MyType {
method postcircumfix:<( )>(MyType:U: $value) {
say "coerced $value";
}
}
say "MyType(3) = {MyType(3)}";
sub xyz($x as MyType) { say $x }
xyz(3);
pmichaud@kiwi:~/p6/rakudo$ ./perl6 y
coerced 3
MyType(3) = True
Unable to coerce value for '$x' from Int to MyType; no coercion method defined
in sub xyz at y:9
in block <anon> at y:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment