docs: clarify string is byte array, move .count to codePoints.count, remove O(n) primitive
The string class is now documented as an immutable byte array rather than a sequence of Unicode code points. The .count getter is removed from the string primitive and replaced by .codePoints.count on the code point sequence interface, making the O(n) cost explicit. Updated the doc site and test files accordingly.
This commit is contained in:
@@ -6,3 +6,13 @@ IO.print("\0".count) // expect: 1
|
||||
IO.print("a\0b".count) // expect: 3
|
||||
IO.print("\0c".count) // expect: 2
|
||||
IO.print(("a\0b" + "\0c").count) // expect: 5
|
||||
|
||||
// Treats a UTF-8 sequence as a single item.
|
||||
//
|
||||
// Bytes: 11111
|
||||
// 012345678901234
|
||||
// Chars: sø mé ஃ thî ng
|
||||
IO.print("søméஃthîng".count) // expect: 10
|
||||
|
||||
// Counts invalid UTF-8 one byte at a time.
|
||||
IO.print("\xefok\xf7".count) // expect: 4
|
||||
|
||||
Reference in New Issue
Block a user