2 ms·
Thank you for that. Who says you can't learn anything by ranting on HN ... :-) As for the inevitable question - if I write text.substring(1) in JavaScript - wh
by chvid 11y ago
Thank you for that. Who says you can't learn anything by ranting on HN ... :-)
As for the inevitable question - if I write text.substring(1) in JavaScript - why are people not asking the same question?
- mikeash 11y agoI don't know why people aren't asking the same question for JavaScript. Certainly, that call is going to cause trouble sometimes. Just try it on the string "<smiley emoji> I love it." (HN is unhappy with emoji, apparently. Surprise! Stuff that doesn't fit into UTF-16 often breaks all sorts of things.) The results are rather unexpected. But it works often enough that I assume people just don't really think about it much. That's the trouble with string manipulation: it's usually easy to make a 99% solution and hard to make a 100% solution. Swift is attempting to prod you into the 100% solution by making the 99% solution more difficult, and the 100% solution maybe a bit easier.