Klitos Kyriacou
03/21/2024, 6:05 PMsize property, just like Arrays and Collections, but they have a length() method instead?Todd
03/21/2024, 6:13 PMlength . Collections such as ArrayList have sizeKlitos Kyriacou
03/21/2024, 6:16 PMlength and yet Kotlin arrays have size. So why not the same with strings?Todd
03/21/2024, 6:23 PMTodd
03/21/2024, 6:24 PMa. Similar to how rust implements len, but I guess Rust chose len instead of size 🤔Klitos Kyriacou
03/21/2024, 6:33 PM"😜".size to be 1? It's 2, because Kotlin (like Java) counts UTF-16 characters.Sam
03/21/2024, 6:35 PMTodd
03/21/2024, 7:01 PMRay Rahke
03/22/2024, 7:05 AMSam
03/22/2024, 7:28 AMनमस्ते (namaste) which is 6 code points forming 4 alphabet characters which—as you'll see if you try to select/copy them—are actually rendered as 3 clusters/symbols. Even in languages with a latin alphabet, a single symbol isn't always well-defined. An ë, for example (e with umlaut), can be represented either by one unicode character (U+00EB) or two (U+0065, U+0308). Both are valid representations of the same text. If we store them as strings, do they have the same length, or different lengths? (Answer: who cares, String length is meaningless).Loney Chou
03/22/2024, 8:04 AMString just shouldn't be CharSequence themselves. An explicit conversion like chars() Which returns a CharSequence is more sound IMO.Loney Chou
03/22/2024, 8:07 AMString is very complex that it shouldn't be as easy as a simple get directly. It will be a fault because of how Unicode behaves.Sam
03/22/2024, 8:09 AMtoByteArray(Charset), most of its functions are actually leaking its implementation details 😞Loney Chou
03/22/2024, 8:11 AMSam
03/22/2024, 8:15 AMInt to reliably represent a code point, though who knows if that'll even be future proof 😄