summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-12-10 17:44:54 +0000
committerPaul Phillips <paulp@improving.org>2009-12-10 17:44:54 +0000
commit71e3f77d35460f202c7c661c447d5cd34e76f5b2 (patch)
tree54bc03a394e6257aad40a3d8a544731e83368397 /src
parent441f16c01bf501a137f30f96e0c8597157364459 (diff)
downloadscala-71e3f77d35460f202c7c661c447d5cd34e76f5b2.tar.gz
scala-71e3f77d35460f202c7c661c447d5cd34e76f5b2.tar.bz2
scala-71e3f77d35460f202c7c661c447d5cd34e76f5b2.zip
Remedying the fact that I swapped which version...
Remedying the fact that I swapped which version of List.fromString was to be deprecated and which was to be deleted, plus some better deprecation advice.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/List.scala32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index d181cf5f29..acb1438f6c 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -613,7 +613,7 @@ object List extends SeqFactory[List] {
* Returns the `Left` values in the given `Iterable`
* of `Either`s.
*/
- @deprecated("use `Either.lefts' instead")
+ @deprecated("use `xs partialMap { case Left(x: A) => x }' instead")
def lefts[A, B](es: Iterable[Either[A, B]]) =
es.foldRight[List[A]](Nil)((e, as) => e match {
case Left(a) => a :: as
@@ -623,7 +623,7 @@ object List extends SeqFactory[List] {
/**
* Returns the `Right` values in the given`Iterable` of `Either`s.
*/
- @deprecated("use `Either.rights' instead")
+ @deprecated("use `xs partialMap { case Right(x: B) => x }' instead")
def rights[A, B](es: Iterable[Either[A, B]]) =
es.foldRight[List[B]](Nil)((e, bs) => e match {
case Left(_) => bs
@@ -636,7 +636,7 @@ object List extends SeqFactory[List] {
* @return a pair of lists.
*/
@deprecated("use `Either.separate' instead")
- def separate[A,B](es: Iterable[Either[A,B]]): (List[A], List[B]) =
+ def separate[A,B](es: Iterable[Either[A, B]]): (List[A], List[B]) =
es.foldRight[(List[A], List[B])]((Nil, Nil)) {
case (Left(a), (lefts, rights)) => (a :: lefts, rights)
case (Right(b), (lefts, rights)) => (lefts, b :: rights)
@@ -679,13 +679,25 @@ object List extends SeqFactory[List] {
res
}
- /** Returns the given string as a list of characters.
- *
- * @param str the string to convert.
- * @return the string as a list of characters.
- */
- @deprecated("use `str.toList' instead")
- def fromString(str: String): List[Char] = str.toList
+ /** Parses a string which contains substrings separated by a
+ * separator character and returns a list of all substrings.
+ *
+ * @param str the string to parse
+ * @param separator the separator character
+ * @return the list of substrings
+ */
+ @deprecated("use `str.split(separator).toList' instead")
+ def fromString(str: String, separator: Char): List[String] = {
+ var words: List[String] = Nil
+ var pos = str.length()
+ while (pos > 0) {
+ val pos1 = str.lastIndexOf(separator, pos - 1)
+ if (pos1 + 1 < pos)
+ words = str.substring(pos1 + 1, pos) :: words
+ pos = pos1
+ }
+ words
+ }
/** Returns the given list of characters as a string.
*