up previous next
A string literal consists of a sequence of characters between double
quotes ("...").
/**/ PrintLn "The primes up to 10 are ", [n in 1..10 | IsPrime(n)];
The primes up to 10 are [2, 3, 5, 7]
/**/ Print "The quick brown fox", "jumped over the lazy dog.";
The quick brown foxjumped over the lazy dog
|
To put special characters in CoCoA string literals use the appropriate
escape sequence. Here is a summary:
\" produces a double-quote character;
\n produces a newline character;
\\ produces a backslash character;
\t produces a TAB character;
\r produces a carriage-return character.
/**/ Print "line 1\nline 2";
line 1
line 2
/**/ Print "A string containing \"quote marks\".";
A string containing "quote marks".
|
WARNING: for backward compatibility CoCoA still accepts an
obsolescent
syntax for string literals (between single-quotes); do not use this!