Why use escaping characters?


#1

On exercise 3 in the Strings and Console Output, why would we use \ when there’s an error? Would it not be easier to just replace the string with “” instead of using \ ? What or when would be the purpose of using an escape character?

Strings and Console Output


#2

yes, that would be easier. The lesson is teaching a concept. What if you string needs to contain both apostrophes and quotation marks? You need to escape one of the two, so this concept has to be taught.


#3

This concept is used when there’s multiple “escapes” to be made. A quote with an apostrophe in it, perhaps. While the code used to teach the concept can be manipulated in different ways, as things become more complex it is always wise to have these concepts in the forefront of your mind.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.