Fork me on GitHub
#clojurescript
<
2023-11-27
>
borkdude14:11:59

Is this the recommended way in CLJS to skip a truthiness check?

(let [^boolean x (js/document.getElementById "app")]
  (if x 1 2))

dnolen14:11:33

skipping truthiness is really quite a low level check

dnolen14:11:39

I think it’s gratuitous here

borkdude14:11:52

(The code is just an example, not something I'm using, but just wanted to know how to do it in general)

dnolen14:11:19

yes, if something is hinted as boolean you will skip it

thheller14:11:40

since that returns nil if the element does not exist you could also use (if (nil? x) 2 1), thats a straight up x == null comparison