May 2018
Beginner to intermediate
290 pages
6h 43m
English
Examples of destructuring are easy to find if you look around in the Clojure ecosystem. For example, Korma,[21] the database library, contains this function, which helps set up connections to MySQL databases:
| | (defn mysql |
| | "Create a database specification for a |
| | mysql database. Opts should include |
| | keys for :db, :user, and :password. |
| | You can also optionally set host and port. |
| | Delimiters are automatically set to \"`\"." |
| | [{:keys [host port db make-pool?] |
| | :or {host "localhost", port 3306, db "", make-pool? true} |
| | :as opts}] |
| | |
| | ;; Do something with host, port, db, make-pool? and opts |
| | ) |
Again we have the typical function with a docstring setup, but this function is using some interesting destructuring to ...
Read now
Unlock full access