4 ms·
This overloads the backslash \(). Which is usually used for escaping characters. Like, \n for new line. So, you may end up with code like: print(“Hi. \nMy
by blackrock 6y ago
This overloads the backslash \().
Which is usually used for escaping characters. Like, \n for new line.
So, you may end up with code like:
print(“Hi. \nMy name is \(name).”)
- Someone 6y agoAnd do you think that’s good or bad? I think it’s nice that there is only one escape character. You check for ‘\’. If it’s there, switch on the next character checking for ‘n’, ‘t’, ‘r’ or ‘(‘, defaulting to appending the unmodified character to the output. I think that might not only be simpler, but also be slightly faster than having having two different escapes would be.
- saagarjha 6y agoI think the intent here is that you are escaping into an interpolation context…