This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-21
Channels
- # announcements (5)
- # babashka (81)
- # beginners (26)
- # calva (6)
- # cider (7)
- # clojure (26)
- # clojure-czech (1)
- # clojure-europe (19)
- # clojure-nl (4)
- # clojure-spec (5)
- # clojure-uk (21)
- # clojuredesign-podcast (2)
- # clojurescript (19)
- # conjure (6)
- # cursive (13)
- # datomic (2)
- # depstar (1)
- # editors (2)
- # graalvm (25)
- # honeysql (5)
- # jackdaw (4)
- # jobs (5)
- # lsp (8)
- # malli (13)
- # music (1)
- # polylith (3)
- # practicalli (1)
- # releases (1)
- # remote-jobs (2)
- # sci (10)
- # shadow-cljs (5)
- # sql (14)
- # tools-deps (25)
- # xtdb (65)
Hi I’m working with monger the mongoDB Clojure wrapper, I’m trying to create a user on the database, the function seems simple enough
add-user
(add-user db username password)
Adds a new user for this db
but when I do something like this
(db/add-user db "test" "12345")
It gives this error.
java.lang.String cannot be cast to [C
What does this error mean?
If its any help, this is what the function looks like in the monger source code
(defn add-user
"Adds a new user for this db"
[^DB db ^String username ^chars password]
(.addUser db username password))
Thanks in advanceBoth [C
and ^chars
are used for arrays of characters (which is different from String).
Does (db/add-user db "test" (.toCharArray "12345"))
work?
Oh that works! If you don’t mind me asking, whats the difference between (char "12345")
and (.toCharArray "12345")
char
will try to cast its argument to a single character (type is char
) and (.toCharArray "asf")
will return an array of chars (type is similar to char[]
) for a given string
this is called prefix notation.
can i define clojure.test
tests in a loop?
(defn generate-tests
[]
(deftest "major test"
(for [case [1 2 3]]
(testing (str "is " case " = 1")
(is (= 1 case))))))
(macro error)I do it like this:
(defn exercise-case
[x]
(is (= 1 x)
(str "is" x "= 1")))
(deftest exercise-1
(exercise-case 1))
(deftest exercise-2
(exercise-case 2))
(deftest exercise-3
(exercise-case 3))
note that the second arg to is
is printed on test failure, just like testing
but it can be calculated on demand in its scopeyup, i get triggered every time i read through https://github.com/ptaoussanis/sente
Is it best practice under Linux to install leiningen from the distro's package manager, or should I install something under my user?
The package manage will be slightly simpler and familiar process and should ensure the binaries do not conflict with anything else on the execution path.
If you wish to have a specific version, then install in _/.local/bin
which is on most exec paths by default if that directory exists.
If configuring a multi-user system and then install in /user/local/bin
using sudo instead.