3 ms·
Rust has similar but it scales infinitely. They're called raw strings, "normal string can contain ' " r#" raw string can contain " ' "# r###" if for some
by conradludgate 5y ago
Rust has similar but it scales infinitely. They're called raw strings,
"normal string can contain ' "
r#" raw string can contain " ' "#
r###" if for some reason you need to write "# "###
Kinda like heredocs
- 0xdeadb00f 5y agoMost (newer) programming languages have a concept of multi-line string literals.
- conradludgate 5y agoMost newer languages only have 1 variation, not infinite. Go only has backtick, python only has triple quotes. Rust has #", ##", ###", ##...#"
- Rendello 5y agoMy favourite variation is from Zig: const hello_world_in_c = \\#include <stdio.h> \\ \\int main(int argc, char **argv) { \\ printf("hello world\n"); \\ return 0; \\} ; It neatly sidesteps the whole "cat-and-mouse" issue. Pair this with the fact that it only has the C++ style // comments, it means that every line can be tokenized independently. Not that that particularly matters for programmers, but I know Vim sometimes gets confused about where Python's strings end and it turns the syntax highlighting to garbage.
- afiori 5y agoit also fixes the indentation problem