空字符串

基本类型 / 字符串

(require '[clojure.string :as str])

;; 空字符串字面量
(def some-empty-string "")
;; 凭空构造
(def another-empty-string (str))

(when (empty? some-empty-string)
  (println "some string is empty"))

(when (empty? another-empty-string)
  (println "another string is empty"))

;; blank? 对 nil 和仅含空格的字符串也返回 true
(when (str/blank? "   ")
  (println "a string of spaces is blank"))