目录

Show 例子

逻辑运算符用于计算布尔表达式。 以下是Groovy中可用的逻辑运算符。

操作者 描述
and 这是逻辑“和”运算符 (或者说真的)会给出真实的
or 这是逻辑“或”运算符 (而真假)会给出错误的
not 这是逻辑“非”运算符 (不是假的)会给出真实的

以下代码段显示了如何使用各种运算符。

例子 (Example)

(ns clojure.examples.hello
   (:gen-class))
;; This program displays Hello World
(defn Example []
   (def x (or true true))
   (println x)
   (def x (and true false))
   (println x)
   (def x (not true))
   (println x))
(Example)

上述程序产生以下输出。

输出 (Output)

true
false
false
↑回到顶部↑
WIKI教程 @2018