3 ms·
Powershell: "This is a string with an 'embedded quote'." It's helpful to remember that quotes will interpret the variables inside, while apostrophes will not.
by stephengillie 9y ago
Powershell: "This is a string with an 'embedded quote'."
It's helpful to remember that quotes will interpret the variables inside, while apostrophes will not. Very useful for scripting the creation of scripts. Example:
"It is $time" > It is 15:22
'It is $time' > It is $time
"'$time' is $time" > '$time' is 15:22
- alanh 9y agonot sure why you were downvoted. Your comment is relevant and the convention can be useful. (PHP worked exactly the same way as your first two examples, although the third would have produced <'15:22' is 15:22>.)
- dragonwriter 9y agoThat's not a string where the same thing used for quoting is used inside the string without escaping, nor is it an example of the distinct begin-vs-end quote pairs approach under discussion. But, yes, having single and double quoted strings is another way to avoid escaping (which Ruby and a number of other languages discussed as supporting the approach being discussed also support.)