This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-04
Channels
- # admin-announcements (3)
- # alda (4)
- # beginners (30)
- # boot (116)
- # cbus (5)
- # cider (20)
- # clara (10)
- # cljs-dev (12)
- # cljsjs (41)
- # cljsrn (9)
- # clojars (6)
- # clojure (131)
- # clojure-bangladesh (5)
- # clojure-colombia (2)
- # clojure-dev (9)
- # clojure-ireland (4)
- # clojure-japan (3)
- # clojure-norway (10)
- # clojure-poland (6)
- # clojure-russia (59)
- # clojure-sg (1)
- # clojurebridge (2)
- # clojurescript (76)
- # clojurewerkz (4)
- # css (6)
- # cursive (21)
- # data-science (24)
- # datomic (27)
- # emacs (9)
- # hoplon (68)
- # jobs (2)
- # jobs-rus (1)
- # ldnclj (10)
- # lein-figwheel (9)
- # leiningen (21)
- # off-topic (5)
- # om (232)
- # onyx (63)
- # parinfer (2)
- # proton (25)
- # re-frame (12)
- # reagent (39)
- # untangled (6)
- # yada (122)
(defn some-func [{:keys [id name]}] (do-something id))
Is there a way to use the {:keys} shortcut but also have a reference to whatever map contained those keys?@urbanslug: so I’d like to destructure some keys of a map in the function, but I’d also like to have a reference to the full map
(also found this https://gist.github.com/john2x/e1dca953548bfdfb9844#shortcuts which seems to agree)
Yeah, :as
is needed when dealing with arguments to a function. For let
though, you have the map on the right hand side, which is the difference
(defn show [{:keys [slug lang] :as university}] (str university))
<— this isn’t quite right. Would you mind correcting this?
if i have a function such as if
, and i want it to simply return an integer if it evaluates to true, at runtime it complains about not being able to convert an Integer to an IFun ... which means i'm probably missing something... consider this code:
(if (= jobcount remaining)
(jobcount)
(wait-for-job-results queue-url (- jobcount remaining)))))
that (jobcount)
is where it goes wrongIf you put something in parens, clojure will call it as a function. For example, if you try to evaluate (1)
in the repl, it will throw the same error.
@lmergen: I'm quite sure I've made that mistake more than once. Don't feel too bad about it.
apparently, clojure gives me the need to add parens around everything, because otherwise things don't look right