# Dynamic equality checking, and Equatable

**URL:** <https://forums.swift.org/t/dynamic-equality-checking-and-equatable/24556>\
**Category:** Discussion\
**Tags:** equality, reflection\
**Created:** [May 15, 2019, 9:05pm UTC](https://forums.swift.org/t/dynamic-equality-checking-and-equatable/24556 "2019-05-15T21:05:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![rex-remind](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rex-remind/32/449_2.png) [@rex-remind](https://forums.swift.org/u/rex-remind)\
**Post date:** [May 16, 2019, 4:12am UTC](https://forums.swift.org/t/dynamic-equality-checking-and-equatable/24556/7 "2019-05-16T04:12:34Z")

</div>

Don't want to dismiss this idea outright but I think there need to be stronger use cases. Your first example makes me wonder why you're comparing those two arrays to begin with. Your second can be solved using algebraic data types or at a minimum can use what's stated here [Adding a polymorphic Equatable? - #2 by gwendal.roue](https://forums.swift.org/t/adding-a-polymorphic-equatable/12034/2)

Explicitly, your JSON example can be solved by relying instead on algebraic data types like many open source JSON libraries already offer. This blog post looks like it gives an example [Parsing fields in Codable structs that can be of any JSON type | by Sergio Schechtman Sette | Grand Parade | Medium](https://medium.com/grand-parade/parsing-fields-in-codable-structs-that-can-be-of-any-json-type-e0283d5edb)

Edit for clarity: Conforming `enum JSONValue: Equality` from that blog example should work since all associated values are Equatable.

---

_[View the full topic](https://forums.swift.org/t/dynamic-equality-checking-and-equatable/24556)._
