I am trying to write a module in ruby and whenever i use a comparison operator i get the above error. none of the operators work.
if self.health >= opponent.health
[:attack, opponent]
else
[:rest]
end
Please let me know if I’m doing some kind of a mistake.
Thanks!
>=can be used only with Comparable objects. Your error message indicates thatself.healthisnil. You need to have a Comparable object for bothself.healthandopponent.health, and further have comparison defined between them.