Clojure-nested-if-statement
提供:Dev Guides
Clojure-ネストされたIfステートメント
他のプログラミング言語で可能なように、複数の「if」ステートメントを相互に埋め込む必要がある場合があります。 Clojureでは、複数の式を評価するときに論理的な「and」を使用することでこれが可能になります。
構文
このステートメントの一般的な形式は次のとおりです。
if(and condition1 condition2) statement #1 statement #2
例
以下は、複数の条件を実装する方法の例です。
(ns clojure.examples.hello
(:gen-class))
;; This program displays Hello World
(defn Example [] (
if ( and (= 2 2) (= 3 3))
(println "Values are equal")
(println "Values are not equal")))
(Example)
出力
上記のコードは次の出力を生成します。
Values are equal