【发布时间】:2014-02-01 15:23:26
【问题描述】:
各种 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"]))
我知道 Clojure 支持多行 String 文字,但使用这种方法会导致换行符被解释的不良影响,例如使用repl:
user=> (println "The quick brown fox
#_=> jumps over the lazy dog")
The quick brown fox
jumps over the lazy dog
【问题讨论】:
-
@Chiron:“有没有一种惯用的方法来避免长字符串文字?”是不是真的有问题?真的吗?我的初等教育都是谎言吗?