In REPL, when you input
(= [1 2 3] (list 1 2 3))
You'll get a true. Does it mean that a list can be identical with a vector?
No, a clojure.lang.PersistentList can never be identical? to a clojure.lang.IPersistentVector -- they are different types, and obviously objects of different types can not be the same object. Therefore they can not be identical.
They can, however, be equal. = in Clojure checks equality, not identity, and calls the equals method that every Object has in Java. Both lists and vectors implement equals by determining whether the contents of the list/vector are equal to the contents of the other collection (if the other object is not a collection, it will return false).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With