On 10/14/22 01:43, WhatMeWorry via Digitalmars-d-learn wrote:
Does D provide any guidance as to what is preferred or are they identical for 
all intents and purposes?

You won't see a difference for this specific example since the split function 
supports character, string and even range separators. So, use what works best 
for your use case.

But here's the difference between them:

Single quotes are for singular characters, 'hello' won't compile while ';' and 
'\n' (escaped newline) will.

Double quotes are string literals, i.e. array of characters, which also allow escape 
sequences like "\r\n".

Back ticks, as well as r"...", are raw or wysiwyg ("what you see is what you 
get") strings, they do not support escape sequences. They are super useful for regex.

import std;
void main() {
    writeln("ab\ncd");  // \n is recognized as a newline character
    writeln(`ab\ncd`);  // `...` and r"..." are equivalent
    writeln(r"ab\ncd");
}

will print:

ab
cd
ab\ncd
ab\ncd

More info here, if you are interested: 
https://dlang.org/spec/lex.html#string_literals

Reply via email to