Skip to content

Commit 7c68757

Browse files
szeigerlrytz
authored andcommitted
Make StringOps a pure value class
This is the same treatment we gave ArrayOps previously. Some of the more complex and nonsensical (for Strings) operations are provided for compatibility. They delegate to WrappedString. Most operations have efficient implementations in StringOps.
1 parent 68bad81 commit 7c68757

File tree

8 files changed

+1101
-234
lines changed

8 files changed

+1101
-234
lines changed

src/library/scala/collection/ArrayOps.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object ArrayOps {
2121
var i = 0
2222
while(i < len) {
2323
val x = xs(i)
24-
if(p(x)) f(xs(i))
24+
if(p(x)) f(x)
2525
i += 1
2626
}
2727
}
@@ -263,12 +263,12 @@ final class ArrayOps[A](val xs: Array[A]) extends AnyVal {
263263
* Note: `c splitAt n` is equivalent to `(c take n, c drop n)`.
264264
*
265265
* @param n the position at which to split.
266-
* @return a pair of arrayss consisting of the first `n`
266+
* @return a pair of arrays consisting of the first `n`
267267
* elements of this array, and the other elements.
268268
*/
269269
def splitAt(n: Int): (Array[A], Array[A]) = (take(n), drop(n))
270270

271-
/** A pair of, first, all elements that satisfy prediacte `p` and, second, all elements that do not. */
271+
/** A pair of, first, all elements that satisfy predicate `p` and, second, all elements that do not. */
272272
def partition(p: A => Boolean): (Array[A], Array[A]) = {
273273
var res1, res2 = ArrayBuilder.make[A]
274274
var i = 0

0 commit comments

Comments
 (0)