Created
July 2, 2012 18:40
-
-
Save ynonp/3034824 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
package Paper; use Moose; | |
package Scissors; use Moose; | |
package Rock; use Moose; | |
package Game; | |
use Moose; | |
use MooseX::MultiMethods; | |
multi method play (Paper $x, Rock $y) { 1 } | |
multi method play (Scissors $x, Paper $y) { 1 } | |
multi method play (Rock $x, Scissors $y) { 1 } | |
multi method play (Any $x, Any $y) { 0 } | |
my $game = Game->new; | |
print $game->play(Paper->new, Rock->new); # 1, Paper covers Rock | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment