Skip to content

Instantly share code, notes, and snippets.

@visibletrap
Last active June 4, 2016 01:49
Show Gist options
  • Save visibletrap/cd00fb1a21ae3bbd1ade06eae407362c to your computer and use it in GitHub Desktop.
Save visibletrap/cd00fb1a21ae3bbd1ade06eae407362c to your computer and use it in GitHub Desktop.
Sample of the way to use each approach to comment code in Clojure
; This line is commented out
(this-code-will-be-executed) ; (this-code-will-not-be-executed)
(defn developing-function [& _] )
(comment ; Use this in development. Remove it when finish.
(developing-fuction 1 2 3 4)) ; Send inner expression to the repl
; #_ is use to comment out an expression quickly
(defn sameple-code
[api]
(when-let [uri (swagger-spec-path api)]
(let [{status :status :as response} (api {:request-method :get
:uri uri
mw/rethrow-exceptions? true})
body (-> response :body slurp (cheshire/parse-string true))]
#_(when-not (= status 200)
(throw (ex-info (str "Coudn't read swagger spec from " uri)
{:status status
:body body}))) ; This line and 3 lines above will not be executed
(when-let [errors (seq (v/validate body))]
(throw (ex-info (str "Invalid swagger spec from " uri)
{:errors errors
:body body})))))
api)
; Source code of function sameple-code is taken and adapted from compojure-api project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment