I\'m in an introductory software development class, and my homework is to create a rock paper scissors program that takes two arguments (rock, paper), etc, and returns the arg t
I very much doubt you've seen array/set intersections, so just for fun:
def who_wins(p1, p2)
win_moves = {"rock" => "paper", "paper" => "scissors", "scissors" => "rock"}
([p1, p2] & win_moves.values_at(p1, p2)).first
end
who_wins("rock", "paper") # "paper"
who_wins("scissors", "rock") # "rock"
who_wins("scissors", "scissors") # nil