M
Matt Beckley
Trying to write code for rock paper scissors game and read in two values
from people playing. Take those values and determine the outcome. As I
understand an array you are able to compare values with the <=> and I
think this is the big jump I need to making things work. I would have
something like this:
a = [rock,paper,scissors] #Comparison array
b = [userinput1 , userinput2] #User store .a values
if userinput1 < userinput2 #loop for showing who wins
elsif userinput1 > userinput2
else userinput1 == userinput2
So my question is how do I go about comparing my two arrays to determine
a outcome? I think a hash is the way to go, not sure how to make the
jump. please include code. Thanks,
from people playing. Take those values and determine the outcome. As I
understand an array you are able to compare values with the <=> and I
think this is the big jump I need to making things work. I would have
something like this:
a = [rock,paper,scissors] #Comparison array
b = [userinput1 , userinput2] #User store .a values
if userinput1 < userinput2 #loop for showing who wins
elsif userinput1 > userinput2
else userinput1 == userinput2
So my question is how do I go about comparing my two arrays to determine
a outcome? I think a hash is the way to go, not sure how to make the
jump. please include code. Thanks,