Content deleted Content added
Remove redlinked hatnote per WP:REDHAT |
cleanup, typo(s) fixed: For example → For example, |
||
Line 10:
</syntaxhighlight>
Two types of literal expression are usually offered: one with interpolation enabled, the other without. Non-interpolated strings may also [[escape sequence]]s, in which case they are termed a [[raw string]], though in other cases this is separate, yielding three classes of raw string, non-interpolated (but escaped) string, interpolated (and escaped) string. For example, in Unix shells, single-quoted strings are raw, while double-quoted strings are interpolated. Placeholders are usually represented by a bare or a named [[sigil (computer programming)|sigil]] (typically <code>$</code> or <code>%</code>), e.g. <code>$apples</code> or <code>%apples</code>, or with braces, e.g. <code>{apples}</code>, sometimes both, e.g. <code>${apples}</code>. In some cases additional formatting specifiers can be used (as in printf), e.g. <code>{apples:3}</code>, and in some cases the formatting specifiers themselves can be interpolated, e.g. <code>{apples:width}</code>. Expansion of the string usually occurs at [[run time (program lifecycle phase)|run time]].
Language support for string interpolation varies widely. Some languages do not offer string interpolation, instead using concatenation, simple formatting functions, or template libraries. String interpolation is common in many [[programming language]]s which make heavy use of [[String (computer science)|string]] representations of data, such as [[Groovy (programming language)|Apache Groovy]], [[Julia (programming language)|Julia]], [[Kotlin (programming language)|Kotlin]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[Swift (programming language)|Swift]], [[Tcl]] and most [[Unix shell]]s.
|