Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this supposed to be better than python? "Every string is an f-string, make sure you don't accidentally miss some interpolation." sounds like a step down, not like an improvement to me!


What do you mean by "miss some interpolation"?

There are two errors you could make in Python. Accidentally using {} in a normal string where you wanted interpolation, and accidentally using {} in an f-string where you wanted literal {}. I definitely do the former a lot.


The escape character is \. Same as in Python. But in Python you have to watch out for \ AND {. In Swift, only \.

And you can do this:

####"foo ###\(this is not interpolation) ####\(but this is) bar"####

In Pythons f-strings you can't ever write the literal `{foo}` in a string for documentation for example. It's a mess.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: