Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure Equality of Symbols

I'm having trouble with a clojure project, and I cannot seem to find an answer. I am trying to compare two symbols:

'x  'y

But when I use:

(= ('x 'y))

It returns true. The same with:

(identical? 'x 'y)

I have found that identical compares memory addresses, but I have not found why 'x and 'y when compared return true? I have not seen a question like this, most of the other posts compare numbers.

like image 985
thisisnotabus Avatar asked Dec 06 '22 11:12

thisisnotabus


1 Answers

You are comparing a list of symbols to nothing. If you only pass one argument to =, it returns true by default. Just remove the parentheses around the symbols and then you'll be comparing the symbols themselves. (= 'x 'y).

like image 92
octopusgrabbus Avatar answered Dec 11 '22 11:12

octopusgrabbus