4 ms·
The core.match example uses python-style triple quotes. Is that actually possible in clojure? I would be enormously excited if it is.
by trothoun 13y ago
The core.match example uses python-style triple quotes. Is that actually possible in clojure? I would be enormously excited if it is.
- omaranto 13y agoI don't think clojure has triple-quoted strings. Something like """ a """ parses as three strings, two of which are empty: "", "\na\n", and "". (Clojure strings are allowed to contain literal newlines.)
- adambard 13y agoHah, so it is. It was pretty late when I finished this one off, sorry about that.
- michaelochurch 13y agoI tried it at a REPL in version 1.5.1 and it didn't work for me. I don't think standard Clojure has triple-quote strings.
- tobik 13y agowhy? in clojure strings can be multiline already. so there is no point in triple quotes.
- drcode 13y agoSo you don't have to escape internal quotes.
- michaelochurch 13y agoTriple quotes tend to come up for two purposes: 1. Long regular expression strings that have quote marks involved. I'm not a fan of large, complex regexes, but a lot of people dislike the line-noise added by escaping. 2. Docstrings that may have quotes in them. It's to remove the string escaping that makes literals look different from the strings they describe.
- tobik 13y agoThanks. Thinking about it, I guess triple-quoted strings also facilitate doctests involving strings that would otherwise be really awkward to read/write.
- adambard 13y agoNo, it's not, my bad. Not that there's a need for them, as it turns out.