This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-22
Channels
- # beginners (17)
- # cider (3)
- # cljsrn (18)
- # clojure (76)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-nl (3)
- # clojure-poland (1)
- # clojure-uk (5)
- # clojurescript (33)
- # core-async (10)
- # datomic (31)
- # duct (5)
- # emacs (4)
- # fulcro (1)
- # graphql (5)
- # keechma (3)
- # off-topic (36)
- # onyx (1)
- # re-frame (4)
- # reagent (9)
- # reitit (9)
- # shadow-cljs (11)
- # vim (2)
@dpsutton thanks! well, I just trying out exercises in
and running tests with lein test
, it works but throws a weird error if I try to require clojure.string for some reason…
Caused by: clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:
In: [1] val: ((require (quote [clojure.string :as s]))) fails spec: :clojure.core.specs.alpha/ns-form at: [:args] predicate: (cat :docstring (? string?) :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses), Extra input
{:clojure.spec.alpha/problems [{:path [:args], :reason "Extra input", :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :clauses :clojure.core.specs.alpha/ns-clauses), :val ((require (quote [clojure.string :as s]))), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x4f186450 "[email protected]"], :clojure.spec.alpha/value (testns (require (quote [clojure.string :as s]))), :clojure.spec.alpha/args (testns (require (quote [clojure.string :as s])))}
at clojure.core$ex_info.invokeStatic(core.clj:4739)
at clojure.core$ex_info.invoke(core.clj:4739)
at clojure.spec.alpha$macroexpand_check.invokeStatic(alpha.clj:689)
at clojure.spec.alpha$macroexpand_check.invoke(alpha.clj:681)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.lang.Compiler.checkSpecs(Compiler.java:6889)
@dimitri In an ns
form, it should be (:require [clojure.string :as s])
Looks like you have (require '[clojure.string :as s])
instead?
oh, using :require
worked! However, all the examples I saw used require
with ns
, why is that?
@dimitri Where did you see examples showing (require '[...])
inside ns
? That's never been officially legal (sure, it worked pre-1.9, but it was bad code).
There's a function require
and that needs a quote. But the ns
form should be :require
without the '
.
I'm done with my first ClojureScript demo. Thanks for all the help Clojurians! I mentioned the Clojurians Slack as a great place for asking Clojure/ClojureScript related help in my blog: https://medium.com/@kari.marttila/become-a-full-stack-developer-with-clojure-and-clojurescript-c58c93479294
Is there an elegant way to build a java.util.Properties from a map? I know it could be done by writing a short function but I’m a bit surprised there isn’t a conversion function already available in the standard library.
(let [props (java.util.Properties.)] (.putAll props m) props)
Or more succinctly
(doto (java.util.Properties.) (.putAll m))