Let’s say I have 4 characters, A, P, B, N. I want to be able to compare them such that:
A > P > B > N > A
How would this be accomplished in Ruby?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From your comments, it seems that you are not trying to put these elements in order, but rather define some binary relation between some of them. It’s possible to do that in Ruby in many ways, depending on how you intend to use that relation later.
The simplest one is just to define ordered pairs of related elements:
And then use it whenever you need to “compare” two elements.
PS. You can generate the map from a string using something like