diff options
author | Paul Phillips <paulp@improving.org> | 2010-01-13 13:08:53 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-01-13 13:08:53 +0000 |
commit | 6b9fe986afcd5a3c61c6a738033bc535cd6751de (patch) | |
tree | fffed976ff46619775f533bde25f5faa625df99d /src/library | |
parent | 895280684fc63f56f5822114118b3275dac7ec5c (diff) | |
download | scala-6b9fe986afcd5a3c61c6a738033bc535cd6751de.tar.gz scala-6b9fe986afcd5a3c61c6a738033bc535cd6751de.tar.bz2 scala-6b9fe986afcd5a3c61c6a738033bc535cd6751de.zip |
Overrode slice in the StringLike derivatives to...
Overrode slice in the StringLike derivatives to use substring. Closes
#2895. Review by community.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/immutable/StringOps.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/WrappedString.scala | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/StringOps.scala b/src/library/scala/collection/immutable/StringOps.scala index db6479742b..95509ab9d6 100644 --- a/src/library/scala/collection/immutable/StringOps.scala +++ b/src/library/scala/collection/immutable/StringOps.scala @@ -25,5 +25,8 @@ final class StringOps(override val repr: String) extends StringLike[String] { /** Creates a string builder buffer as builder for this class */ override protected[this] def newBuilder = new StringBuilder + override def slice(from: Int, until: Int): String = + repr.substring(from max 0, until min repr.length) + override def toString = repr } diff --git a/src/library/scala/collection/immutable/WrappedString.scala b/src/library/scala/collection/immutable/WrappedString.scala index e535cddfce..e10b3ab0ee 100644 --- a/src/library/scala/collection/immutable/WrappedString.scala +++ b/src/library/scala/collection/immutable/WrappedString.scala @@ -26,6 +26,9 @@ class WrappedString(override val self: String) extends IndexedSeq[Char] with Str /** Creates a string builder buffer as builder for this class */ override protected[this] def newBuilder = WrappedString.newBuilder + + override def slice(from: Int, until: Int): WrappedString = + new WrappedString(self.substring(from max 0, until min self.length)) } /** |