Make strings iterable over their code points.

I'm not sure why, but this also regresses perf:

binary_trees - wren            ..........  3290  0.30s   96.68% relative to baseline
delta_blue - wren              ..........  7948  0.13s   99.06% relative to baseline
fib - wren                     ..........  3165  0.32s   95.90% relative to baseline
for - wren                     ..........  8242  0.12s   96.00% relative to baseline
method_call - wren             ..........  5417  0.18s   78.74% relative to baseline

Need to investigate.
This commit is contained in:
Bob Nystrom
2015-01-22 20:58:22 -08:00
parent a5b00cebe7
commit eb424f5c1a
14 changed files with 141 additions and 21 deletions
+13
View File
@@ -56,6 +56,19 @@ Returns the index of the first byte matching `search` in the string or `-1` if
It is a runtime error if `search` is not a string.
### **iterate**(iterator), **iteratorValue**(iterator)
Implements the [iterator protocol](../control-flow.html#the-iterator-protocol)
for iterating over the *code points* in the string:
:::dart
var codePoints = []
for (c in "(ᵔᴥᵔ)") {
codePoints.add(c)
}
IO.print(codePoints) // ["(", "ᵔ", "ᴥ", "ᵔ", ")"].
### **startsWith**(prefix)
Checks if the string starts with `prefix`.