String Literals
Part of TutorialIntermediate
Shows how different types of string literals work.
Example
/* "Backquote" WYSIWYG strings */ const string a1 = `\`; const string b1 = `\\`; const string c1 = `\"`; /* r"" WYSIWYG strings */ const string a2 = r"\"; const string b2 = r"\\"; const string c2 = r"\" `"`; /* The r"" strings can't contain a ", so I used concatenation. */ /* "Regular strings */ const string a3 = "\\"; const string b3 = "\\\\"; const string c3 = "\\\""; void main() { writef("Test that the strings mean what I think they mean.\n"); assert(a1 == a2); assert(a1 == a3); assert(b1 == b2); assert(b1 == b3); assert(c1 == c2); assert(c1 == c3); writef("Tests passed!\n"); }
Source
| Link | http://www.dsource.org/tutorials/index.php?show_example=98 |
| Posted by | jcc7 |
| Date/Time | Sat Jun 19, 2004 4:30 pm |
