Skip to content

Instantly share code, notes, and snippets.

@stuarthalloway
Created October 13, 2017 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuarthalloway/4d2215d5f7506104ea06ad727a608c43 to your computer and use it in GitHub Desktop.
Save stuarthalloway/4d2215d5f7506104ea06ad727a608c43 to your computer and use it in GitHub Desktop.
Using clojure reset!
;; fix for code shown at https://twitter.com/metcarob/status/918764898041188352
(def recieved-slack-vars (atom {}))
;; unnecessarily complex
(defn return-second-arg [arg1 arg2]
arg2)
(defn set-recieved-slack-vars
[newval]
(swap! recieved-slack-vars return-second-arg newval))
(set-recieved-slack-vars {:botname "Test"})
;; fixed
(reset! recieved-slack-vars {:botname "Test"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment