-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
The Clojure Workshop
By :
In the previous section, we learned how to import Clojure functions using refer. In this section, we will learn how we can import Clojure functions with require and use.
While refer allows us to literally refer to other namespaces' vars without fully qualifying them, often we need more than that. In the previous exercise, we imported a namespace and accessed vars such as fruits from it without using the namespace name as a prefix to the garden/fruits var. Often, we want to load functions from a namespace and use those functions. If we want to read the file, we need to import code from the Clojure I/O library (the library for input-output operations such as reading and writing files).
With the require function, we will load a namespace that we'll specify. This way, functions from the loaded namespace are available in our namespace for use. This is a great way to write Clojure code, reuse existing functions, and make them...