(Boolean. false) in Clojure

后端 未结 3 1421
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 17:11

According to http://hyperpolyglot.org/lisp, the only falsehoods in Clojure are false and nil. Indeed, surprisingly enough, (Boolean. false)

3条回答
  •  不思量自难忘°
    2020-12-11 17:26

    I think the reason this happens is that Clojure's = uses Java's equals method. So (= x y) is like x.equals(y). So false gets coerced into (Boolean. false) in the comparison under the hood.

    Note that this does not mean that (Boolean. false) is false or that it is the 'same' as false, just that when false and (Boolean. false) are compared using the equals method they are considered to be equal.

提交回复
热议问题