xwu
(Xiaodi Wu)
October 25, 2020, 5:46pm
2
This is the subject of a number of prior threads. It's unclear if there's much to say at the moment on the topic which hasn't already been covered in the conversations below, and as a result some of these conversations have devolved until they're locked:
Hello,
I made an implementation like an extension of String, to work with substrings and characters with Int types and not String.Index. It uses String.Index internally and error control in code, but you can use all the ranges and positions in a String with Int.
It implements ClosedRange, Range, PartialRangeFrom, PartialRangeUpTo and PartialRangeThrough. Always returns a Substring. And you can use an Int to retrieve a Character type of the element of the position you asked.
It will be great t…
Nope. But I can see why you're confused about my position. I'm advocating against using the cumbersome syntax altogether. I'm suggesting you instead use the iterator, or functions such as prefix and family. I'm suggesting that if you're trying to access specific indices of the character sequence, you're probably doing something wrong, and your algorithm is probably ported from some pseudo code that assumes both trivial encoding and presentation.
If you for some niche reason really need random …
Previously, I had skip/keep but that looked a bit weird in a subscript on the LHS of an assignment, because it replaces the thing you're "keeping". Before that I had skip/next, which reads better, but is slightly odd in the end-relative case, where it means "next to the left". There probably isn't any single word that is totally clear on its own.
If we can cover the basic functionality (and meet the basic requirements) in a straightforward, consistent way, I don't see a problem adding "convenie…
3 Likes