Class BacktickString
EK9 has two String literals. A double-quoted String is plain text and is never interpolated, so a
${...} inside one prints as those characters — almost always a misunderstanding carried from
Kotlin, Groovy, Dart, PHP or a shell, where double quotes DO interpolate. The compiler therefore
rejects ${ in a double-quoted String (E07901). A backtick String is interpolated:
${...} evaluates, and \$ writes a literal dollar.
🔑 So such a text has exactly two backtick spellings, and both come from here:
interpolating(String) (every ${...} evaluates — what the writer almost always meant) and
literal(String) (every ${ kept as characters). Both escape what a backtick String needs
and a double-quoted one does not — a $ that opens no interpolation, and a backtick — write
\" as a plain " (a backtick String needs no escape for it), and carry every other escape
pair (\n, \$, ...) over as written. The concatenation rewriter renders its literal
segments through literal(String) too, so there is one rule for all three.
The compiler's E07901 message and the tooling's applied repair both call this, so the spelling the message names is always the spelling the repair writes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanholdsInterpolation(String doubleQuotedText) Does the text between a double-quoted String's quotes hold${?static Stringinterpolating(String doubleQuotedText) The backtick String, delimiters included, in which every${...}of the text evaluates.static StringThe backtick String, delimiters included, whose value keeps every${as characters.
-
Method Details
-
holdsInterpolation
Does the text between a double-quoted String's quotes hold${? -
interpolating
-
literal
-