Johnny Brown
Johnny Brown

Reputation: 1000

Why does (= (vector nil) (vec nil)) return false?

Is this just a quirk, or is there some fundamental concept that implies this?

Upvotes: 8

Views: 910

Answers (2)

MayDaniel
MayDaniel

Reputation: 1484

user> (vec nil) ; => []

user> (vector nil) ; => [nil]

user> (= *1 *2) ; => false

Why should these be equal?

Upvotes: 6

DaVinci
DaVinci

Reputation: 1391

vec converts into a vector(nil becomes an empty vector) while vector creates a vector with the given elements.

(vec nil) => []
(vector nil) => [nil]

you could have entered these expressions into a repl to see their results and why they're not equal.

Upvotes: 21

Related Questions