This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-14
Channels
- # adventofcode (38)
- # announcements (42)
- # aws (3)
- # babashka (8)
- # beginners (165)
- # calva (36)
- # chlorine-clover (14)
- # cider (6)
- # clj-kondo (5)
- # cljsrn (33)
- # clojure (27)
- # clojure-australia (1)
- # clojure-czech (1)
- # clojure-doc (1)
- # clojure-europe (26)
- # clojure-nl (6)
- # clojure-spec (6)
- # clojure-uk (3)
- # clojurescript (10)
- # code-reviews (20)
- # conjure (1)
- # core-logic (5)
- # cursive (3)
- # data-science (5)
- # datomic (35)
- # emacs (1)
- # figwheel-main (3)
- # fulcro (10)
- # honeysql (1)
- # introduce-yourself (4)
- # jobs (3)
- # jobs-discuss (4)
- # minecraft (2)
- # missionary (28)
- # nextjournal (3)
- # off-topic (45)
- # pathom (7)
- # polylith (1)
- # portal (22)
- # practicalli (2)
- # re-frame (4)
- # reagent (19)
- # releases (3)
- # remote-jobs (3)
- # reveal (1)
- # rum (4)
- # shadow-cljs (37)
- # spacemacs (14)
- # sql (1)
- # tools-build (7)
- # tools-deps (16)
- # vim (13)
- # xtdb (15)
Morning !
Interestingly, TS now has nil-punning truck?.sheep
which is somewhat convenient. But they also have the opposite(?) truck.sheep!
which seems to be a way to instruct TS that even though sheep
is defined as a maybe(sheep)
it is in in fact always a sheep, so the typechecker allows for not checking for nil-ness.
Unfortunately it doesnât seem like TS has https://clojure.org/guides/weird_characters, so itâs unpossible for me to figure out the precise definition of these âŚoperators?
Here we are https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator
Good morning đ
Anyone else ever use values other than actual booleans to express boolean values in order to avoid conflating false
and nil
?
Example:
{:user-wants-to-participate? true
;;required, so boolean value is fine
:user-lives-in-denmark? "no"
;;not required, so the user can opt not to answer,
;;in which case the value will be nil.
;;This can then later be misinterpreted as the boolean value false.
}
Or perhaps youâd rather add a sentinel value for "user opted not to answer"
?
I usually do this for form input, for the reasons already stated. I think itâs the best way if the input needs to be persisted (in a store with predefined colums). Another way would be âkey not present in the map if not answeredâ?
The latter is an example where misinterpretation can happen e.g.
(select-keys [:user-lives-in-denmark?]
{:user-wants-to-participate? true
:user-lives-in-denmark? false})
=> {}
Thanks for your 2 cents!
Itâs certainly something to look out for, and possibly sentinel-value your way out of.
argh, I think I messed up my example. đ
(select-keys {:user-wants-to-participate? true
:user-lives-in-denmark? false}
[:user-lives-in-denmark?])
=> {:user-lives-in-denmark? false}
The reason still stands, though - in some data manipulations, the falseyness of both false
and nil
results in conflation. But perhaps itâs not as bad as I assume.
honestly never had any issues with that. In the cases where there is an issue, your data model is probably just wrong.