String append: Difference between revisions
Content added Content deleted
(Add Go example) |
(jq) |
||
Line 198: | Line 198: | ||
"Goodbye, World!" |
"Goodbye, World!" |
||
</pre> |
</pre> |
||
jq's <code>+</code> operator can be used to append two strings, and under certain circumstances the <code>+=</code> operator can be used as an abbreviation for appending a string to an existing string. For example, all three of the following produce the same output:<lang jq>"Hello" | . += ", world!" |
|||
["Hello"] | .[0] += ", world!" | .[0] |
|||
{ "greeting": "Hello"} | .greeting += ", world!" | .greeting</lang> |
|||
However the <code>+=</code> operator cannot be used with jq variables in the conventional manner. One could however use the technique illustrated by the following:<lang jq>"Hello" as $a | $a | . += ", world!" as $a | $a</lang> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |