From bd9874055fa2fbd2d848e59973c2b6b87f0e1fac Mon Sep 17 00:00:00 2001 From: michelou Date: Fri, 20 Jul 2007 10:46:52 +0000 Subject: minor changes --- src/library/scala/Stream.scala | 6 ++-- src/library/scala/runtime/RichString.scala | 53 +++++++++++++++++------------- 2 files changed, 32 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala index c03c2a72d6..14bfd258d6 100644 --- a/src/library/scala/Stream.scala +++ b/src/library/scala/Stream.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -12,7 +12,6 @@ package scala import Predef._ -import compat.StringBuilder /** * The object Stream provides helper functions @@ -38,7 +37,6 @@ object Stream { protected def addDefinedElems(buf: StringBuilder, prefix: String): StringBuilder = buf } - object cons { /** A stream consisting of a given first element and remaining elements * @param hd The first element of the result stream diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 3c7d68f84f..c109b9c9cb 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -19,35 +19,42 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char override def length = self.length override def toString = self override def mkString = self - override def slice(from : Int, until : Int) : RichString = { + + 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)) } + //override def ++ [B >: A](that: Iterable[B]): Seq[B] = { - override def ++[B >: Char](that : Iterable[B]) : RandomAccessSeq[B] = that match { - case that : RichString => new RichString(self + that.self) - case that => super.++(that) + override def ++[B >: Char](that: Iterable[B]): RandomAccessSeq[B] = that match { + case that: RichString => new RichString(self + that.self) + case that => super.++(that) } - override def take(until : Int) : RichString = slice(0, until) - override def drop(from : Int) : RichString = slice(from, self.length) - override def startsWith[B](that : Seq[B]) = that match { - case that : RichString => self startsWith that.self - case that => super.startsWith(that) + override def take(until: Int): RichString = slice(0, until) + + override def drop(from: Int): RichString = slice(from, self.length) + + override def startsWith[B](that: Seq[B]) = that match { + case that: RichString => self startsWith that.self + case that => super.startsWith(that) } - override def endsWith[B](that : Seq[B]) = that match { - case that : RichString => self endsWith that.self - case that => super.endsWith(that) + + override def endsWith[B](that: Seq[B]) = that match { + case that: RichString => self endsWith that.self + case that => super.endsWith(that) } - override def indexOf[B](that : Seq[B]) = that match { - case that : RichString => self indexOf that.self - case that => super.indexOf(that) + + override def indexOf[B](that: Seq[B]) = that match { + case that: RichString => self indexOf that.self + case that => super.indexOf(that) } - override def containsSlice[B](that : Seq[B]) = that match { - case that : RichString => self contains that.self - case that => super.containsSlice(that) + + override def containsSlice[B](that: Seq[B]) = that match { + case that: RichString => self contains that.self + case that => super.containsSlice(that) } override def compare(other: String) = self compareTo other @@ -169,11 +176,11 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char self.split(re) } - def toByte: Byte = java.lang.Byte.parseByte(self) - def toShort: Short = java.lang.Short.parseShort(self) - def toInt: Int = java.lang.Integer.parseInt(self) - def toLong: Long = java.lang.Long.parseLong(self) - def toFloat: Float = java.lang.Float.parseFloat(self) + def toByte: Byte = java.lang.Byte.parseByte(self) + def toShort: Short = java.lang.Short.parseShort(self) + def toInt: Int = java.lang.Integer.parseInt(self) + def toLong: Long = java.lang.Long.parseLong(self) + def toFloat: Float = java.lang.Float.parseFloat(self) def toDouble: Double = java.lang.Double.parseDouble(self) } -- cgit v1.2.3