有时候,就像其他编程语言一样,要求相互之间嵌入多个" if"语句。
以下是此声明的一般形式。
if(and condition1 condition2) statement #1 statement #2
以下是如何实现多个条件的示例。
(ns clojure.examples.hello (:gen-class)) ;; This program displays Hello Learnfk (defn Example [] ( if ( and (= 2 2) (= 3 3)) (println "Values are equal") (println "Values are not equal"))) (Example)
上面的代码产生以下输出。
Values are equal
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)