Created
July 7, 2010 13:04
-
-
Save jjn1056/466660 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subtype PStr, | |
as Parameterizable[Str, Int), | |
where { length(shift) < shift) }; | |
method(Int $length = 10) | |
my_name(PStr[$length] $name) | |
{ | |
return "Hello $name!"; | |
} | |
say $self->my_name->with(5)->('JohnN'); | |
say $self->my_name(10,'JohnN'); ## "Hello JohnN!" | |
say $self->my_name(2,'JohnN'); ## dies with constraint violation | |
my $cb = $self->my_name(10); | |
say $self->$cb('JohnN'); ## "Hello JohnN!" | |
subtype UniqueID, | |
as Parameterizable[Int, ResultSet], | |
where { ! $_->[1]->find($_->[0]) }; | |
method(Object $rs = sub {shift->rs} ) | |
my_name(UniqueID[$rs] $id) | |
{ | |
## Something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment