Skip to content

Instantly share code, notes, and snippets.

@rightfold

rightfold/.pm6 Secret

Last active January 25, 2016 19:06
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 rightfold/f536f9be6d4729ec8377 to your computer and use it in GitHub Desktop.
Save rightfold/f536f9be6d4729ec8377 to your computer and use it in GitHub Desktop.
use v6.c;
subset T of List where *[0] eqv 1;
class R {
multi method f(T:D $xs) { self.f(42) }
multi method f(Any:D $xs) { say $xs }
}
R.f([1, 2]);
R.f([2, 2]);
@masak
Copy link

masak commented Jan 25, 2016

subset T of List where { .[0] == 1 };

class C {
    multi method f(T:D $xs) { self.f(42) }
    multi method f(Any:D $xs) { say $xs }
}

C.new.f([1, 2]);
C.new.f([2, 2]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment