From 71e3f77d35460f202c7c661c447d5cd34e76f5b2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 10 Dec 2009 17:44:54 +0000 Subject: 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. --- src/library/scala/collection/immutable/List.scala | 32 ++++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/library') 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. * -- cgit v1.2.3