summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-11-13 17:49:56 +0000
committermichelou <michelou@epfl.ch>2007-11-13 17:49:56 +0000
commit96f925078fdcf764e84f4691e6589004f09ca709 (patch)
tree007d4a188f8ccb80d58a6f81642d9b8f1fc730cd /src/library
parentbdc8a6a607b599a7292e55a45634f2177c77ee76 (diff)
downloadscala-96f925078fdcf764e84f4691e6589004f09ca709.tar.gz
scala-96f925078fdcf764e84f4691e6589004f09ca709.tar.bz2
scala-96f925078fdcf764e84f4691e6589004f09ca709.zip
fixed partest, removed mergeLines (useless)
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/runtime/RichString.scala33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala
index 187f77e5d3..40fccab5ba 100644
--- a/src/library/scala/runtime/RichString.scala
+++ b/src/library/scala/runtime/RichString.scala
@@ -22,10 +22,16 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char
override def mkString = self
override def slice(from: Int, until: Int): RichString = {
- val from0 = if (from < 0) 0 else from
- val until0 = if (from >= until || from >= self.length) return new RichString("")
- else if (until > self.length) self.length else until
- new RichString(self.substring(from0, until0))
+ val len = self.length
+ new RichString(
+ if (from >= until || from >= len)
+ ""
+ else {
+ val from0 = if (from < 0) 0 else from
+ val until0 = if (until > len) len else until
+ self.substring(from0, until0)
+ }
+ )
}
//override def ++ [B >: A](that: Iterable[B]): Seq[B] = {
@@ -159,25 +165,6 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char
*/
def stripMargin: String = stripMargin('|')
- /** <p>
- * Remove white space from both ends of each line and add
- * a blank (" ") between lines before merging them.
- * </p>
- * <p>
- * Equivalent to: <code>mergeLines(_.trim, " ")</code>.
- * </p>
- */
- def mergeLines: String = mergeLines(_.trim, " ")
-
- /** <p>
- * Apply function <code>f</code> to each line and add
- * the string <code>eol</code> between lines before
- * merging them.
- * </p>
- */
- def mergeLines(f: String => String, eol: String): String =
- lines map f mkString eol
-
private def escape(ch: Char): String = ch match {
case '.' | '$' | '^' | '\\' => "\\" + ch
case _ => "" + ch