抑制 REPL 中的输出
suppress output in REPL
当调用 returns REPL 打印输出的函数时。如何在不临时将 nil
添加为函数的最后一行的情况下抑制此打印?
这很容易做到。例如,如果您有一个名为 f
的函数,那么您可以这样调用它:
(f)
;; hello yes this is f
;;=> :huge
但是如果你想忽略输出,你可以这样做:
(do (f) nil)
;; hello yes this is f
;;=> nil
如果您愿意,您还可以定义一个 ignore
函数来为您执行此操作:
(def ignore (constantly nil))
(ignore (f))
;; hello yes this is f
;;=> nil
当调用 returns REPL 打印输出的函数时。如何在不临时将 nil
添加为函数的最后一行的情况下抑制此打印?
这很容易做到。例如,如果您有一个名为 f
的函数,那么您可以这样调用它:
(f)
;; hello yes this is f
;;=> :huge
但是如果你想忽略输出,你可以这样做:
(do (f) nil)
;; hello yes this is f
;;=> nil
如果您愿意,您还可以定义一个 ignore
函数来为您执行此操作:
(def ignore (constantly nil))
(ignore (f))
;; hello yes this is f
;;=> nil