0

I'd like to compare two instances of the same struct to see if their fields have all the same value. I believe that according to the docs the equality operator wont't work on structs.

What would be the right approach here? Writing a custom equals method for the struct?

alilloig
  • 456
  • 1
  • 4
  • 11

1 Answers1

2

I believe your instincts are right, a custom equals method would be best. Other languages allow for for custom comparators so you can do things like create your own == operator for structs. But that’s not a feature atm in Cadence, so an equals methods like you suggested would work in this instance.