store/[org.clojure/clojure "1.8.0"] clj::clojure.core/in-ns

Official Documentation

Add notes

  Sets *ns* to the namespace named by the symbol, creating it if needed.

Example 1

;; Let's create new namespace, create new variable in it, then access it from another namespace

;; create the namespace and switch to it
(in-ns 'first-namespace)
;; => #<Namespace first-namespace>

;; create a variable and check it
(def my-var "some value")
;; => #'first-namespace/my-var
;; => "some value"

;; create another namespace and switch to this one
(in-ns 'second-namespace)
;; => #<Namespace second-namespace>

;; use variable from the other namespace here
;; => "some value"

Example 2

;; The "in-ns" function works almost the same as "ns", but does not load clojure.core 

(in-ns 'my-namespace)
#<Namespace my-namespace>

;; The function clojure.core/inc won't just work becayse
;; the "my-namespace" ns is empty and doesn't alias in all the defs
;; from clojure.core. As a result if we just say inc...
(inc 1)
;; => java.lang.Exception: Unable to resolve symbol: inc in this context (NO_SOURCE_FILE:15)
;; we can't find it.

;; We can however use the fully qualified name to refer to inc despite
;; not having aliased it in.
(clojure.core/inc 1)
;; => 2

Uses on crossclj