相关疑难解决方法(0)

是否有一种惯用的方法来避免长Clojure字符串文字?

各种Clojure风格指南建议避免使用超过80个字符的行.我想知道是否有一种惯用的方法来避免长String文字.

虽然这些日子通常有宽屏幕,但我仍然同意应该避免长线.

以下是一些例子(我很想跟随第一个例子):

;; break the String literal with `str`
(println (str
    "The quick brown fox "
    "jumps over the lazy dog"))

;; break the String literal with `join`
(println (join " " [
    "The quick brown fox"
    "jumps over the lazy dog"]))
Run Code Online (Sandbox Code Playgroud)

我知道Clojure支持多行String文字,但使用这种方法会有解释换行符的不良影响,例如使用repl:

user=> (println "The quick brown fox
  #_=>   jumps over the lazy dog")
The quick brown fox
  jumps over the lazy dog
Run Code Online (Sandbox Code Playgroud)

idiomatic clojure

14
推荐指数
1
解决办法
2614
查看次数

标签 统计

clojure ×1

idiomatic ×1