Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created August 3, 2016 15:07
Show Gist options
  • Save zoffixznet/ae6d37d1c45e0207c6884adec847ceb6 to your computer and use it in GitHub Desktop.
Save zoffixznet/ae6d37d1c45e0207c6884adec847ceb6 to your computer and use it in GitHub Desktop.
enum Hand <Rock Paper Scissors>;
multi infix:<πŸ‘Š>(Paper, Rock) { True }
multi infix:<πŸ‘Š>(Rock, Scissors) { True }
multi infix:<πŸ‘Š>(Scissors, Paper) { True }
multi infix:<πŸ‘Š>($, $) { False }
my $p1 = Hand.roll;
say "Player 1 chooses {$p1}";
my $p2 = Hand.roll;
say "Player 2 chooses {$p2}";
say do {
when $p1 πŸ‘Š $p2 { "Player 1 wins!" }
when $p2 πŸ‘Š $p1 { "Player 2 wins!" }
default { "It's a tie!" }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment