Clojure-namespace

提供:Dev Guides
2020年6月22日 (月) 22:43時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

Clojure- ns

これは、現在のネームスペースを見るために使用されます。

構文

構文は次のとおりです。

(*ns*)

パラメータ-なし。

戻り値-現在実行中のプログラムの名前空間を返します。

以下は、Clojureの名前空間の例です。

(ns clojure.examples.example
   (:require [clojure.set :as set])
   (:gen-class))
(defn example []
   (println *ns*))
(example)

出力

上記のプログラムは、次の出力を生成します。

#object[clojure.lang.Namespace 0x50ad3bc1 clojure.examples.hello]

ご覧のとおり、上記のプログラムの出力は、現在のネームスペースの名前であるclojure.examples.helloとしてネームスペースを表示します。