Fork me on GitHub
#clojurescript
<
2023-07-19
>
DeepReef1120:07:15

What's the proper way to translate the "?" in clojurescript?

parent.document.getElementById(slot)?.childElementCount
Am I suppose to use (when-not (empty? %)) Seems like it doesn't work that way because of the chaining

p-himik20:07:55

Or when-some (`when-let` is also suitable when false is not in the domain).

DeepReef1121:07:06

What is supposed to follow some->? I tried % but it doesn't work

cjohansen21:07:00

(some-> parent .-document (.getElementById slot) .-childElementCount)

DeepReef1121:07:59

Is the following also fine?

(-> js/document
                                                          (some->
                                                          (.getElementById slot)

                                                          (.childElementCount)
                                                          ))

cjohansen21:07:59

It’ll work, but it has unnecessary nesting and is harder to read

DeepReef1117:07:29

Where could I learn more about this? I'm not sure I understand (some-> parent .-document (.getElementById slot) .-childElementCount) . Are dashes used to mention what some-> is for?

p-himik17:07:20

(doc some->) for some->.

p-himik17:07:41

Dashes are interop with JS, they denote JS properties.

2