Namespaces in Clojure are used to distinguish classes into separate logical parts. It's used when we have multiple imported classes in our code. The all-ns
method works with namespaces.
The all-ns
method is used to get the namespaces of our code.
(all-ns)
The all-ns
method does not take any parameters.
The all-ns
method returns all the namespaces of our code. This simply means that wherever the all-ns
method is used, it returns all the namespaces that our code is working with. Let's look at an example.
(ns clojure.examples(:gen-class))(defn func [](println all-ns))(func)
In the code above, we see the following:
func.
all-ns
method and print the output. Note: The output is an object containing all the namespaces our code is working with.
func.