This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-27
Channels
- # announcements (24)
- # babashka (26)
- # beginners (8)
- # calva (8)
- # clojure (78)
- # clojure-europe (1)
- # clojure-norway (22)
- # clojurescript (14)
- # datascript (5)
- # datomic (8)
- # fulcro (22)
- # helix (9)
- # humbleui (11)
- # malli (4)
- # off-topic (28)
- # pedestal (5)
- # reitit (10)
- # shadow-cljs (2)
- # tools-build (8)
- # tools-deps (9)
In clojure i can use java interop to parse integers and floats from strings, but what's the canonical way to do it in clojurescript?
You don't need interop for that, neither in CLJ nor in CLJS - there are built-in parse-long
and parse-double
.
Is there no built-in for integers? https://clojuredocs.org/clojure.core/int
No. Unless you're dealing specifically with interop, Clojure's numbers are either longs or doubles.
I don't care that much for the internals of the number though, i just want to make sure that it's mathematically an integer. I'll see if i can work it out with parsing and integer? then
> i just want to make sure that it's mathematically an integer
Then parse-long
is what you need, no?
> That's an interesting design decision
In practice, most of the problems don't require differentiating between integer types.
So much so that e.g. Python went further and combined them all together into an unbound int
.
The differentiation might be needed to make something more efficient in some way. And most of the time you can do it just fine in Clojure.